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

Categories

0 votes
273 views
in Technique[技术] by (71.8m points)

.net - Remove character in string that is between curly braces


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

1 Answer

0 votes
by (71.8m points)

Replace all occurrences of this regex with the empty String:

;(?=[^{}]*})

This matches a semicolon but only when followed by 0 or more characters that are not { or } then a }, which is the same as saying “only when the next curly brace character is a close curly brace”

As code:

line = Regex.Replace(line, ";(?=[^{}]*})", "");

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...