Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Is there any way to completely ignore line break and tab characters etc. in RegEx? For instance, the line break and tab characters could be found anywhere and in any order in the content string.

... [CustomToken  
 Type="User"  
 Property="FirstName" 
 /] ... [CT ...

The is the RegularExpression that I am currently using:

([CustomToken).*?(/])

.NET API

Regex.Matches(string input, string pattern)

Thanks for your suggestion.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
553 views
Welcome To Ask or Share your Answers For Others

1 Answer

If you just want that regex to match that input, all you need to do is specify Singleline mode:

Regex.Matches(input, @"[CustomToken).*?(/])", RegexOptions.Singleline);

The dot metacharacter normally matches any character except linefeed ( ). Singleline mode, also known as "dot-matches-all" or "DOTALL" mode, allows it to match linefeeds as well.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...