27 Feb 2012 at 11:50 #1 Izi Izi Soldato Joined 9 Dec 2007 Posts 2,718 Anyone fancy helping me with some regex? I need to match "1d 1h 1m" Where the user could just enter 1m or 1h or 1d or a combination of the three. The numbers can change for example 2d 5h 24m. I hate regex.
Anyone fancy helping me with some regex? I need to match "1d 1h 1m" Where the user could just enter 1m or 1h or 1d or a combination of the three. The numbers can change for example 2d 5h 24m. I hate regex.
27 Feb 2012 at 12:09 #2 GravyMonster GravyMonster Soldato Joined 18 Oct 2002 Posts 15,558 Location The land of milk & beans Code: \d+d \d+h \d+m http://regexr.com?30512 Regexr is a great site for messing around with regex.
27 Feb 2012 at 12:14 #3 Izi Izi Soldato OP Joined 9 Dec 2007 Posts 2,718 Spunkey said: Code: \d+d \d+h \d+m http://regexr.com?30512 Regexr is a great site for messing around with regex. Click to expand... cheers Spunkey - used this site before. I should have said, it wasn't this part that was a struggle. It was the either or part. I.E still matching: 1d or 60m or 1d 50m etc. Is this possible?
Spunkey said: Code: \d+d \d+h \d+m http://regexr.com?30512 Regexr is a great site for messing around with regex. Click to expand... cheers Spunkey - used this site before. I should have said, it wasn't this part that was a struggle. It was the either or part. I.E still matching: 1d or 60m or 1d 50m etc. Is this possible?
27 Feb 2012 at 12:39 #4 GravyMonster GravyMonster Soldato Joined 18 Oct 2002 Posts 15,558 Location The land of milk & beans Ah sorry, missed that bit. To cover those you would need to include the 'or' operator, | Code: \d+d|\d+h|\d+m http://regexr.com?3051k
Ah sorry, missed that bit. To cover those you would need to include the 'or' operator, | Code: \d+d|\d+h|\d+m http://regexr.com?3051k
27 Feb 2012 at 12:51 #5 Izi Izi Soldato OP Joined 9 Dec 2007 Posts 2,718 Great, thanks! that was easier than I thought.
28 Feb 2012 at 00:04 #6 Bes Bes Soldato Joined 18 Oct 2002 Posts 7,318 Location Melbourne How can you hate Regex? Regex is brilliant
28 Feb 2012 at 01:00 #7 meth meth Associate Joined 10 Nov 2003 Posts 72 Location Ye olde land o' many roundabouts Spunkey said: Code: \d+d \d+h \d+m http://regexr.com?30512 Regexr is a great site for messing around with regex. Click to expand... I wish I'd known about this site a week ago, could have saved me several hours! Cheers for the link.
Spunkey said: Code: \d+d \d+h \d+m http://regexr.com?30512 Regexr is a great site for messing around with regex. Click to expand... I wish I'd known about this site a week ago, could have saved me several hours! Cheers for the link.
28 Feb 2012 at 01:51 #8 Scougar Scougar Soldato Joined 30 Jan 2007 Posts 15,484 Location PA, USA (Orig UK) Ah, regular expressions. Awesome and Aggravating all-in-one !