Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NotePad++ replace problem

I have a file with lots of text editing using NotePad++.

for example

<span class="italic">some text</span><span class="bold">another text or some text</span>

I would like to use NotePad++'s regex replace to replace

<span class"italic>some text</span> to <i>some text</i> and <span class="bold">another text or some text</span> to <b>another text or some text</b>

I'm able to match the span text however How to replace them with NotePad++

Find <span class="italic">text12312</span> and replace it with <i>[a-zA-Z]*</i> will actually put the "[a-zA-Z]*" text into replaced string and not "text12312".

like image 933
NgeLay Avatar asked Jul 10 '10 06:07

NgeLay


People also ask

How do I replace text in Notepad?

Open the text file in Notepad. Click Edit on the menu bar, then select Replace in the Edit menu. Once in the Search and Replace window, enter the text you want to find and the text you want to use as a replacement. See our using search and replace and advanced options section for further information and help.


1 Answers

<span class="italic">([^<]+)</span> => <i>\1</i>

<span class="bold">([^<]+)</span> => <b>\1</b>

[^<]+ matches one or more of any character except <, and the parentheses capture it in group #1. \1 inserts the captured text into the replacement string.

like image 126
Alan Moore Avatar answered Nov 10 '22 08:11

Alan Moore