Regex problem
-
I need that Regex won't return match if the string starts with another substring, for example "abc". In detail, "
abcde
" shouldn't match, but "abg
", "gbc
" and "afcgr
" should match. I know the [^abcde] syntax that works for characters, but I couldn't figure out way for substrings. It is possible to do this with Regex? I need it to be done through Regex, not String class methods. Thanks. -
I need that Regex won't return match if the string starts with another substring, for example "abc". In detail, "
abcde
" shouldn't match, but "abg
", "gbc
" and "afcgr
" should match. I know the [^abcde] syntax that works for characters, but I couldn't figure out way for substrings. It is possible to do this with Regex? I need it to be done through Regex, not String class methods. Thanks.Use explicit capture and the following:
(abc.*)|(?a.*)
You can use backtracking too, but i dont really understand it, the above way does the same, kinda :p top secret
Download xacc-ide 0.0.3 now!
See some screenshots -
Use explicit capture and the following:
(abc.*)|(?a.*)
You can use backtracking too, but i dont really understand it, the above way does the same, kinda :p top secret
Download xacc-ide 0.0.3 now!
See some screenshotsI think you missed the point. "abc" should not match. I want to match any combination of three characters, except the above sequence. I can do it as well with two chars. For example, if i want to match anything except "ab", i can use
(?:a[^b])|(?:[^a].)
. But when it comes to three or more characters, i find no way. Maybe I miss something. Thanks. -
I think you missed the point. "abc" should not match. I want to match any combination of three characters, except the above sequence. I can do it as well with two chars. For example, if i want to match anything except "ab", i can use
(?:a[^b])|(?:[^a].)
. But when it comes to three or more characters, i find no way. Maybe I miss something. Thanks. -
I think you missed the point. "abc" should not match. I want to match any combination of three characters, except the above sequence. I can do it as well with two chars. For example, if i want to match anything except "ab", i can use
(?:a[^b])|(?:[^a].)
. But when it comes to three or more characters, i find no way. Maybe I miss something. Thanks.sb777 wrote: Maybe I miss something. Perhaps :) It is infact matched just not returned, well at least not as a named group. Al you have to do is check is
Groups["good"].Success
. As long as your precedence is correct, you can match and 'eleminate' alot of data at once. top secret
Download xacc-ide 0.0.3 now!
See some screenshots -
I think you missed the point. "abc" should not match. I want to match any combination of three characters, except the above sequence. I can do it as well with two chars. For example, if i want to match anything except "ab", i can use
(?:a[^b])|(?:[^a].)
. But when it comes to three or more characters, i find no way. Maybe I miss something. Thanks.TyronX, yous second suggestion did answered my question. thanks a lot. BTW, the first one isn't correct. leppie, Your suggestion could also fit in another constraints, but thanks for the new information.