Hello! prereturn value.match(/FN:(.+)TEL/)[1];/pre should be working
Please check if you have what you expect in value variable. Add before this line prealert(value);/pre and see what you have in alert.
Hello! prereturn value.match(/FN:(.+)TEL/)[1];/pre should be working
Please check if you have what you expect in value variable. Add before this line prealert(value);/pre and see what you have in alert.
Hi Maryna!
When I do the alert(value) the alert that pops up does contain the content as follows:
BEGIN:VCARD VERSION:2.1 FN:Chris Herold TEL;work:888-919-0919 EMAIL;INTERNET;work:a href="mailto:msacl@gmail.com" rel="nofollow"msacl@gmail.com/a END:VCARD
So the data is in value, but for some reason value isn't being parsed correctly by the javascript code.
Do you think it could be that there are semicolons in the content?
I am not sure what to try next.
What do you think?
Sorry no news for now, we'll update when we'll have more information.
Hello,
You can try to add value alerts before and after "match" function. Use next code:
pre
var a= value;
alert(a);
b=a.match(/FN:(.+?)TEL/)[1];
alert(b);
return b;
/pre
So we've got a tricky one here.
codevar a = "BEGIN:VCARD VERSION:2.1 FN:Chris Herold TEL;work:888-919-0919 EMAIL;INTERNET;work:msacl@gmail.com END:VCARD"
alert(value);
b = a.match(/FN:(.+?)TEL/)[1];
alert(b);
return b;/code
The code above will work fine with code var a /code explicitly defined.
The alert to test the content of value codealert(value);/code pops up an alert with the expected content from the barcode scan (which is identical to what is in var a).
The variable codeb/code returns the expected output for the match: "Chris Herold" when the match target is codea/code.
However, when I change the match target from codea/code to codevalue/code, as done below ... nothing works, except the initial alert outputing the content that is identical to the content of var a.
alert b ends up with no value, and hence no alert.
codevar a = "BEGIN:VCARD VERSION:2.1 FN:Chris Herold TEL;work:888-919-0919 EMAIL;INTERNET;work:msacl@gmail.com END:VCARD"
alert(value);
b = value.match(/FN:(.+?)TEL/)[1];
alert(b);
return b;/code
How can this be happening? There must be some way that I need to encase 'value' to have it render properly, perhaps because the content it contains has semicolons????
I figured it out. The data that was being sent in on the VCARD included hidden new line characters ... \n.
It appears that the newline characters MUST BE REMOVED from the contents of "value" for the match to run successfully.
The first line of code below removes the newline characters and replaces them with nothing, using empty quotes. The second line performs the match and returns the value for use in the app.
code
var value = value.replace(/\n/g,"");
return value.match(/FN:(.+?)TEL/)[1];
/code
Thanks for everyone's help on this. You all got me up to speed on remedial javascript and I just needed to look closely at the content of value until I figured it out. Thanks team Appery!
Hello! Glad it's working now! Thank you for update!