January 09, 2011 use of regex -- PS | ||||
---|---|---|---|---|
| ||||
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 |
January 09, 2011 Re: use of regex -- PS | ||||
---|---|---|---|---|
| ||||
Posted in reply to spir | 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
>
|
Copyright © 1999-2021 by the D Language Foundation