PHP RegEx woes

Associate
Joined
23 Mar 2009
Posts
348
Location
Midlands
Hey all!

Still fairly new to RegEx, and really struggling to find an expression to get the URL out of this text:

PHP:
<script type="text/javascript">
					document.write('<li><a href="/oyster/journeyHistoryThrottle.do?_qs=_qv%3Dc2115ef6e2db4509db5d5f1b044f09009b4d3e30">Journey history</a></li>');
				</script>
				<noscript>
					<li><a href="/oyster/journeyHistory.do?_qs=_qv%3Dc2115ef6e2db4509db5d5f1b044f09009b4d3e30">Journey history</a></li>
				</noscript>

The problem is that the value after _qs=_gv changes with each session.
Do you have any ideas how I could get this working? :S

The value I would need is in bold:

document.write('<li><a href="/oyster/journeyHistoryThrottle.do?_qs=_qv%3Dc2115ef6e2db4509db5d5f1b044f09009b4d3e30">Journey history</a></li>');
 
I can do this in Python (if I remember how) but can't help specifically help with the js code you need here but maybe look at it with a few suggestions.

Although the value after _qs=_qv changes, can you not assign it to a variable, find the position of =" and "> as what you want always ends with this and then assign everything in between to a new variable to use?

I should be going to bed but now you've got me pondering...*goes of to look at code*
 
Never mind, found it! Sorry but a mod can close/delete this now :)

Solution:
$pattern = "/<a href=\"\/oyster\/journeyHistoryThrottle.do(.*?)\">Journey history/s";

edit: Thanks aharvey for the help
 
Back
Top Bottom