0

what is the c# equivalent of /x in perl for regex, so the /x at the end would ignore all the whitespaces newlines and whatnot in your regex expression. Otherwise, my expression would be a giant one liner instead of a little block. Any other way around it?

3 Answers 3

5

You're looking for RegexOptions.IgnorePatternWhitespace.

Sign up to request clarification or add additional context in comments.

Comments

2

There's an option you can specify when constructing the Regex:

new Regex("...expression here...", RegexOptions.IgnorePatternWhitespace)

Since RegexOptions is a flag type, you can binary-OR this flag with any existing flags you may specify.

Comments

0

The /x inline character is supported. See here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.