Forum Navigation
Regexes, checking whether a whole string matches
Posted: 11/08/08 16:29:29 Modified: 11/08/08 16:31:44I'm trying to use tango.text.Regex.Regex to determine if a string matches a pattern. I don't want to know if the string contains a match; I want to know if it *IS* a match. It looks like how I would do this is:
bool matches (char[] pattern, char[] input) { Regex r = Regex(pattern); if (!r.test (input)) return false; return r.pre == null && r.post == null; }This isn't straightforward, so I'm not sure it's correct. It's kludgy at best. But is it correct?