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 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 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. 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 no cigar what is the use of % instead of #? 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) 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. Link to comment https://forums.phpfreaks.com/topic/269471-simple-date-regex/#findComment-1385317 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.