I have a page using a javascript marque banner. The contents or elements of this marque have been saved into their own file. I have a page that will add new elements and update or remove existing ones. I need to extract the url and message to be displayed so that I can populate them into form elements. I seem to be having a problem extracting these two elements from the line of javascript.
The file marque_content.js has lines like:
myScroller1.addItem("<b><a href='http://internal.wayport.net'>oakth.lax nmd down with high loads</a></b>");
The modify_marque.php file loads the file into an array and uses a for loop to iterate through the array. In each iteration, we should extract the url and messge from the line of javascript, save them into variables and use these to populate form elements.
I can't find a regular expression to do what I need. I've tried using preg_slit and eregi with no luck. The delimiters for the split are pretty easy to pick out; maybe it is a problem escaping single quotes. Could anyone help with a regular expression that would extract the url and message? I have been using:
$url = preg_split('((href=\')|(\'>))', $line, 1, PREG_SPLIT_DELIM_CAPTURE);
$msg = preg_split('((\'>)|(</a></b>))'), $line, 1, PREG_SPLIT_DELIM_CAPTURE);
This does not feel right. Please help!