digitalmars.D.learn - use of regex -- PS
- spir (12/12) Jan 09 2011 Hello again,
- Jesse Phillips (2/14) Jan 09 2011
Hello again, I also have an issue with the func 'match': instead of simply trying to mat= ch and fail if not found, it seems to search for a matching snippet all alo= ng the source: what a method 'find' or 'search' usually does, as opposed to= 'match' precisely. Thus, i'm forced to prefix all regex patterns with '^'. What am I missing? (If I'm not missing anything, would be useful to have match vs find, don't = you think?) Denis -- -- -- -- -- -- -- vit esse estrany =E2=98=A3 spir.wikidot.com
Jan 09 2011
If you want your regular expression which matches at the begging of the string you use ^ (carrot). A regex is for describing what it takes to make a match, if your regex doesn't use this than it can match anywhere in the string. So to me having a match and find is redundant. I mean what does find do when you have ^ and $ surrounding the expression? spir Wrote:Hello again, I also have an issue with the func 'match': instead of simply trying to match and fail if not found, it seems to search for a matching snippet all along the source: what a method 'find' or 'search' usually does, as opposed to 'match' precisely. Thus, i'm forced to prefix all regex patterns with '^'. What am I missing? (If I'm not missing anything, would be useful to have match vs find, don't you think?) Denis -- -- -- -- -- -- -- vit esse estrany ☣ spir.wikidot.com
Jan 09 2011