C# conditional regex -


i new conditional regex , not sure how achieve below

input string - "test \n string \n\r"

output string - "test r string \n\r"

would replace \n 'r' , leave is, if \n\r

thanks, arthi

you can use negative lookbehind:

regex.replace(string, @"(?s)(?<!\r)\n", "r"); 

this replace \n when not preceded \r


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -