Reputation: 1242
every body.
Could you tell me whether phonegap support regex? I tried to use regex on iOS Phonegap project, but it didn't run.
For example, I use regex to check if a hyperlink, and it not work
var pattn = '^http[s]?\:\/\/[^\/]*';
var url = 'http://google.com';
var regx = new RegExp(pattn, 'gi');
if (url.match(regx)) {
console.log('Match');
}
Upvotes: 0
Views: 493
Reputation: 1242
After diving into Phonegap, I found that Phonegap support regex, but it has a bit different:
var pattn = '^http[s]?\:\/\/[^\/]*';
var url = 'http://google.com';
var regx = new RegExp(pattn, 'gi');
if (regx.test(url)) {
console.log('Match');
}
regx.exec(url);
Upvotes: 1