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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -