c# - Regex Ignore first and last terminator -
i have string in text have uses | delimiter.
example:
|2p|1|u|f8| i want result 2p|1|u|f8. how can that?
the regex easy, why not use trim():
var str = "|2p|1|u|f8|"; str = str.trim(new[] {'|'}); or without new[] {...}:
str = str.trim('|'); output:

in case there leading/trailing whitespaces, can use chained trims:
var str = "\r\n |2p|1|u|f8| \r\n"; str = str.trim().trim('|'); output same.
Comments
Post a Comment