I might just be doing something obvious and dumb here, but I can get this code to work in the Chrome console, but when I run it in my phonegap app it just doesn't do anything.
I'm pulling in some messages from an website API to a phonegap companion app. The problem is the messages have links in them to the website. I want to use regex to change the href to an onClick so it works with my app.
If I run this code in Chrome it's fine:
avar = '<a href="view.php?id=63">Click here to view details</a>';
bvar = avar.replace(
/<a href="view\.php\?id=([0-9])*">/gi,
'<a onClick="navigator.notification.alert(\'ok\')">AAA'
);
I stripped the regex right back to this, and it still fails
bvar = avar.replace(
/<a href="/gi,
'TEST'
);
Again that works in Chrome and not the Phonegap app. Any ideas?
if it seems to have issues with the ", try putting brackets around what you are regex-ing:
also, using the console.log, just check that the regex is getting registered in js correctly.