shahrukh1 Posted October 15, 2012 Share Posted October 15, 2012 I've read this thread http://forums.phpfreaks.com/topic/12377-common-expressions/ I've tried to match my patter to extract the date from this On:</td> <td><strong>9/30/12</strong></td> here is my expression "#On:</td>\s*<td><strong>\s*<td><strong>(1-9){1,2}[\/](1-9){1,2}[\/](1-9){1,2}</strong></td></strong></td>#i" it is not working for me, please help Quote Link to comment https://forums.phpfreaks.com/topic/269471-simple-date-regex/ Share on other sites More sharing options...
DarkerAngel Posted October 15, 2012 Share Posted October 15, 2012 (edited) Try this maybe? '%On:</td>\s*<td><strong>\s*(\d){1,2}[/](\d){1,2}[/](\d){1,2}%i' A couple things I noticed: Your range is only 1-9 missing 0's (Mine is \d matching numerals)(Also it wasn't placed in a range modifier so it would have tried literally matching "1-9") Your opening and closing <td> <strong> html elements are trying to match 2x (on both sides) as oppose to your initial test subject, in which the tags only appear once. Edited October 15, 2012 by DarkerAngel Quote Link to comment https://forums.phpfreaks.com/topic/269471-simple-date-regex/#findComment-1385240 Share on other sites More sharing options...
shahrukh1 Posted October 15, 2012 Author Share Posted October 15, 2012 (edited) no cigar what is the use of % instead of #? Edited October 15, 2012 by shahrukh1 Quote Link to comment https://forums.phpfreaks.com/topic/269471-simple-date-regex/#findComment-1385275 Share on other sites More sharing options...
DarkerAngel Posted October 15, 2012 Share Posted October 15, 2012 Nothing at all, simply put it's only a regex delimiter ( #, %, /, &, ~, ! ), I just normally go with the one RegexBuddy gives me usually saves the "Opps, I'm using that in my expression" problem. '%On:</td>\s*<td><strong>(\d{1,2})/(\d{1,2})/(\d{1,2})%i' Few More Points I guess I missed when I posted previously: For some reason I left the " / " in the [ ] range delimiter even though " / " is not a range I had repetition modifiers outside the capture group resulting in a Last Case capture (in tester) Had a whitespace search after the <strong> tag though it didn't seem to affect the tester This one might work a little better, if not I might need to see more of what you're trying to match against since my tester is reporting it a valid match (as well as capture groups) Quote Link to comment https://forums.phpfreaks.com/topic/269471-simple-date-regex/#findComment-1385279 Share on other sites More sharing options...
shahrukh1 Posted October 15, 2012 Author Share Posted October 15, 2012 thank you it works. Quote Link to comment https://forums.phpfreaks.com/topic/269471-simple-date-regex/#findComment-1385317 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.