Here is my RegEx declaration.

private Regex rxPattern = new Regex("^(book-[a-z]{1}\z)");

I'm expecting it to match start of string "^" To end of string "\z"
But the "z" is causing the error.

I'm fairly new to RegEx and cannot find a solution, if anyone can educate me a little that would be smashing.

Thanks for reading.


I swapped "\z" for "$" and it does not cause error.
But in another project I do use "\z" and it appear to work, but of course I probably just think it does.

Edited by Suzie999

2 Years
Discussion Span
Last Post by DaveAmour

Now I'm getting the same error, but on the "\d" with the following pattern.

public Regex rxPattern = new Regex("^(\d{1,5}$)");

Duh! was missing "@"...

public Regex rxPattern = new Regex(@"^(\d{1,5}$)");

Same with other pattern.

Edited by Suzie999


Absolutely not, that would be absurd.

I'm typing to myself :)

Just wanted to clear up the issue so not waste anyones time.


Fair enough. I don't know much about regex but I always remember the hat and dollar so could have answered this one!


Thanks, but just for clarification.

"\z" was just fine, as was "\d", the problem was my omissiom of "@".

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.