Regex Char Class Subtraction spec available [Kit George]

I propped the character class subtraction specification up on the BCL website:

This feature will be one of the many enhancements we make to Whidbey, so keep an eye out for it in Beta1.

Any feedback on the specification is appreciated!

Comments (6)

  1. Matt C. Wilson says:

    Maybe my in-brain regex parser is buggy, but I think this line was incorrect?

    [-e-f] Valid, not a subtraction. Although this is a valid expression, it is not a subtraction. Instead, this is an expression looking for the minus sign, or any letter a through e.

    I see that as a minus sign, or any letter e through f (so just minus, e, and f).

    Did I miss something?

  2. Dmitriy Zaslavskiy says:

    Would you consider adding a flag to enable/disable this new behaviour it might be easier to port

  3. Kit George says:

    Matt, thanks for that, and I agree: a pretty clear copy/paste error! I’ll get that updated

  4. Kit George says:

    Dmitriy, we didn’t consider this, mostly becuase the cases where there may be conflict with existing expressions are obscure enough that we don’t believe we’ll break any existing code.

    What are you porting to?

  5. Joe White says:

    I saw another minor (but confusing) error toward the bottom of page 3. Under "Impact on Current Behavior", you have a paragraph that starts "Today, this will be interpreted as ‘any a through e character, minus sign, open square bracket, b, d, or close square bracket, immediately followed by a close square bracket’." I think you need to take out the "or close square bracket" — i.e., the character class will not match a right square bracket; the first ] ends the character class, the second ] is matched as a literal, and neither is part of the character class today.

    It might also be nice if you would include a brief mention of how you can make a character class that does include a square bracket, and whether that syntax is affected by the new feature. Do you escape it with a backslash?

  6. Kit George says:

    Joe, nice pick: I just updated the file (check for the update in around a day). I fixed the first part, and I like the second suggestion, I simply have to explore getting that kind of feedback incproporated into the docs, instead of simply this file here, so I’m going to be looking at that option.

    Thanks for the deeback!


Skip to main content