简体   繁体   中英

C# Regex.replace Pattern needed

Usually I make my Regex patterns by myself, but I can't figure this one out:
I need a Regex.Replace that replaces "'Number'/'Number'" to "'Number'von'Number'".

Example: "2/5" schould become "2von5".

The problem is that I can't just replace "/" to "von" because there are other "/" that are needed.

You can replace (?<=\\d)/(?=\\d) with von , using lookaround .

Another option is to replace (\\d)/(\\d) with $1von$2 (though that would fail on 1/2/3 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM