Simple Regex wont work!!! Why?

  • Thread starter Thread starter Ali Eghtebas
  • Start date Start date
A

Ali Eghtebas

Hi,

Why isn't this working? What's wrong with it? Am I missing something here?
Why this pattern wont match the string "cc".
Pattern: [^a].|.[^b] (This should match anything except "ab"
String: cc

While this will: [^a]c|c[^b]

Isn't a . supposed to match everything except \n unless modified by
SingleLine option?
 
Hi there.

Try this

[^A|a].|.[^B|b]

I'm not sure how it works, but I tested it in a RegEx Workbench
utility that I have. It seems to work fine.

Hope this helps.

Jas.
 
Hi,

Well, this isn't what I want. E.g. your expression won't match the string
"ad".
I've tested some more expressions and I think this must be a bug in RegEx.
I think the bug occurs when having a ^ in brackets in the first part and
then
right after the | having a . or \w or any other Character class.
To explain by example look at the pattern below:
[^a].|\w[^b] will not match anything except any string starting with a "b"
e.g. "bu", "ba", "bc", etc. This is very strange!!!
While the pattern [^a].|[a-zA-Z_0-9][^b] which is exactly the same
pattern (\w = [a-zA-Z_0-9]) will work as it should, i.e. it matches
anything but "ab".

Please someone confirm if this is a bug!
 
Hi Chris,

For some strange reason that I can't comprehend, it returns True as you say
if IgnoreCase option is set on.
 
Forgot to mention that then "AB" is also excluded while we only want to
exclude "ab".
 
Back
Top