Or on Mac: http://robrohan.com/projects/widgets/#regexwidget
On Sat, Mar 26, 2011 at 10:45 PM, Simon Holywell <[email protected]> wrote: > A tool I find very useful when trialling regex > is http://weitz.de/regex-coach/ which is free and runs well under Wine if > you are on Linux. > > On 26 March 2011 09:42, Michael Adams <[email protected]> wrote: >> >> Doh... I thought that would stop once it found four digits without looking >> further. Perfect thanks. >> >> On Saturday 26 March 2011 21:32, Simon J Welsh wrote: >> > /myid=([\d]{4,7})/ would match myid=4-7digits and have that in [0] and >> > just >> > the digits in [1]. >> > >> > On 26/03/2011, at 10:05 PM, Michael Adams wrote: >> > > i want to extract a match from a string. I have these working: >> > > >> > > /myid=[0-9][0-9][0-9]/ >> > > >> > > on "index.php?foo=Y&myid=123456&bar=2" >> > > with the result >> > > >> > > Array >> > > ( >> > > [0] => Array >> > > ( >> > > [0] => myid=123 >> > > ) >> > > >> > > ) >> > > >> > > or >> > > >> > > /myid=[0-9]{7}|[0-9]{6}|[0-9]{5}|[0-9]{4}/ >> > > >> > > Array >> > > ( >> > > [0] => Array >> > > ( >> > > [0] => 123456 >> > > ) >> > > >> > > ) >> > > >> > > "myid" is between 4 and seven digits and i need to get the full number >> > > hence why i check for 7 first. >> > > >> > > /myid=[0-9]{7}|myid=[0-9]{6}|myid=[0-9]{5}|myid=[0-9]{4}/ >> > > >> > > Array >> > > ( >> > > [0] => Array >> > > ( >> > > [0] => myid=123456 >> > > ) >> > > >> > > ) >> > > >> > > Just tried this... it works, it is what i want, but it just seems way >> > > OTT. Is there a simpler way? >> > > >> > > Much cleaner would be a way of extracting just the digits after >> > > ensuring >> > > it followed "myid=" but i can do that on a second call if needed. >> > > >> > > TIA >> > > >> > > -- >> > > Michael >> > > >> > > -- >> > > NZ PHP Users Group: http://groups.google.com/group/nzphpug >> > > To post, send email to [email protected] >> > > To unsubscribe, send email to >> > > [email protected] >> > >> > --- >> > Simon Welsh >> > Admin of http://simon.geek.nz/ >> > >> > Who said Microsoft never created a bug-free program? The blue screen >> > never, >> > ever crashes! >> > >> > http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e >> >> -- >> NZ PHP Users Group: http://groups.google.com/group/nzphpug >> To post, send email to [email protected] >> To unsubscribe, send email to >> [email protected] > > > > -- > Simon Holywell > http://www.simonholywell.com > > -- > NZ PHP Users Group: http://groups.google.com/group/nzphpug > To post, send email to [email protected] > To unsubscribe, send email to > [email protected] -- NZ PHP Users Group: http://groups.google.com/group/nzphpug To post, send email to [email protected] To unsubscribe, send email to [email protected]
