c# - Fast way to remove some parts from string -
from following string string1
want remove before "am" , after "uhr"
string string1 = "angebotseröffnung 27.03.2014, 11:00 uhr, ort: vergabestelle, siehe a).";
so @ end have string. "am 27.03.2014, 11:00 uhr".
i using code know not approach. can 1 me better options.
string1 = string1.replace("angebotseröffnung", ""); string1 = string1.replace("ort", ""); string1 = string1.replace("vergabestelle", ""); string1 = string1.replace("siehe", ""); string1 = string1.replace("a)", "");
another option use regex.match.
string output = regex.match(string1, "am.*uhr").value;
but work if have am
, uhr
in string. depending on input may require am.*?uhr
or (?:a|p)m.*?uhr
regex.
Comments
Post a Comment