nyke0 Posted August 27, 2014 Posted August 27, 2014 (edited) #include <Array.au3> $sString = '<a href="http://www.google.com" target="_blank">Google</a> <a rel="nofollow" href="http://maps.google.com" target="_blank">Google Maps</a>' $aLink = StringRegExp($sString, 'href="(.+)" target', 3) _ArrayDisplay($aLink, 'aLink')Result: http://www.google.com" target="_blank">Google</a> <a rel="nofollow" href="http://maps.google.com But I want: http://www.google.com He should stop by the first 'target' not by the last, how I get that? Edited August 27, 2014 by nyke0
mikell Posted August 27, 2014 Posted August 27, 2014 (edited) ? #include <Array.au3> $sString = '<a href="http://www.google.com" target="_blank">Google</a> <a rel="nofollow" href="http://maps.google.com" target="_blank">Google Maps</a>' $aLink = StringRegExp($sString, 'href="([^"]+)', 1) _ArrayDisplay($aLink, 'aLink') To get both links, put a 3 instead of 1 as last parameter Edit To make your expression work, you must use the lazy quantifier '?' $aLink = StringRegExp($sString, 'href="(.+?)" target', 3) Edited August 27, 2014 by mikell
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now