I have a piece of code that looks for links and puts them into an onClick event:
var regex = /href\s?=\s?"\s?([\S]+)"/g;
var newText = $sanitize(text).replace(regex, "onClick=\"window.open('$1', '_system', 'location=yes')\"");
The only issue is that for particularly long links it looks like a newline is probably added because when I try to click on the links the expected result doesn't happen (I also copy and paste the links into my text editor and there appears to be a line break). Here is an example of the link:
window.open('http://somedomain.com/subscription/some-report-text/issue/the-deadliest-word-on-the-
planet-could-bring-savvy-investors-extraordinary-profits/?u=000071340856&vid=TatDiU&a=MMP&o=9637385?u=000071340856&vid=8ALdFM&a=MMP&o=6530827?u=000071340856&vid=9Vm2j_&a=MMP&o=1652570?u=000071340856&vid=Cd_ME9&a=MMP&o=8995371', '_system', 'location=yes')
Is there another regular expression I can run to get rid of line breaks from within my new links? Or is there something wrong with my first expression?
p.s. what is the secret to learning regular expressions?