Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find/Replace regex to remove html tags

Using find and replace, what regex would remove the tags surrounding something like this:

<option value="863">Viticulture and Enology</option>

Note: the option value changes to different numbers, but using a regular expression to remove numbers is acceptable

I am still trying to learn but I can't get it to work.

I'm not using it to parse HTML, I have data from one of our company websites that we need in excel, but our designer deleted the original data file and we need it back. I have a list of the options and need to remove the HTML tags, using Notepad++ to find and replace

like image 775
stewart715 Avatar asked Apr 27 '11 17:04

stewart715


People also ask

How do you remove tags in HTML?

For HTML tags, you can press Alt+Enter and select Remove tag instead of removing an opening tag and then a closing tag.

Can I use regex in replace?

The Regex. Replace(String, String, MatchEvaluator, RegexOptions) method is useful for replacing a regular expression match if any of the following conditions is true: If the replacement string cannot readily be specified by a regular expression replacement pattern.

Can regex remove characters?

To replace or remove characters that don't match a regex, call the replace() method on the string passing it a regular expression that uses the caret ^ symbol, e.g. /[^a-z]+/ . The replace method will return new string where the not matching characters are replaced or removed. Copied!


2 Answers

This works for me Notepad++ 5.8.6 (UNICODE)

search : <option value="\d+">(.*?)</option>

replace : $1

Be sure to select "Regular expression" and ". matches newline" enter image description here

like image 126
Toto Avatar answered Sep 19 '22 11:09

Toto


I have done by using following regular expression:

Find this : <.*?>|</.*?>

and

replace with : \r\n (this for new line)

By using this regular expression (<.*?>|</.*?>) we can easily find value between your HTML tags like below:

enter image description here

I have input:

<otpion value="123">1</option><otpion value="1234">2</option><otpion value="1235">3</option><otpion value="1236">4</option><otpion value="1237">5</option> 

I need to find values between options like 1,2,3,4,5

enter image description here

and got below output :

enter image description here

like image 23
Sunil Kumar Avatar answered Sep 19 '22 11:09

Sunil Kumar