Removing an element from the content of a string value which is HTML code
-
Hi, I have a string variable which the value is html code. I like to check to see if certain word (in this case EEST) exist in the first
element as you can see in the sample. Then I like to remove that element and its content from the string.
Some text here, 26 APRIL 2017 AT 9:00 AM EEST. some other content here as well>
much other elements here as well
then the output becomes:
much other elements here as well
I was wondering, how I can do such task. Thank you.
-
Hi, I have a string variable which the value is html code. I like to check to see if certain word (in this case EEST) exist in the first
element as you can see in the sample. Then I like to remove that element and its content from the string.
Some text here, 26 APRIL 2017 AT 9:00 AM EEST. some other content here as well>
much other elements here as well
then the output becomes:
much other elements here as well
I was wondering, how I can do such task. Thank you.
Try a regex:
public static Regex regex = new Regex(
"\\<p\\sclass=\"myclass\"\\>.*?\\sEEST.*?\\>\\</p\\>",
RegexOptions.IgnoreCase
| RegexOptions.CultureInvariant
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled
);Then just use Replace:
string result = regex.Replace(inputText,"");
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!
-
Try a regex:
public static Regex regex = new Regex(
"\\<p\\sclass=\"myclass\"\\>.*?\\sEEST.*?\\>\\</p\\>",
RegexOptions.IgnoreCase
| RegexOptions.CultureInvariant
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled
);Then just use Replace:
string result = regex.Replace(inputText,"");
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!
You are amazing! Thanks! :)
-
You are amazing! Thanks! :)
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!