问题
I have a lot of php pages. Every php page has inside a string like this:
<FONT COLOR="#0000FF">Post ID: 16107</FONT>
and I'd like to replace with:
<A HREF="#16107">Post ID: 16107</A>
but since every php page has a different Post ID and I'd like to match every occurrence of the string... I use as usually notepad2 witch supports regex and notepad++ too that supports regex as well. How can I replace all strings into all files into all dirs? Are about 350 files...
回答1:
Replace: <FONT COLOR=".*?">(Post ID: ([0-9]+))</FONT>
With: <A HREF="#\2">\1</A>
回答2:
search for
<FONT COLOR=".*?">Post ID: (\d+)<\/FONT>
replace with
<A HREF="#$1">Post ID: $1<\/A>
回答3:
Good to know this is possible:
In Notepad++ you'd need to search for Keep ID: ([0-9]*) and replace it with New ID: $1.
$0represents the whole thing found,$1the first found in brackets.- you can use
[]to create a class (in this case of numbers 0 to 9) - and finally the asterisk tells the parser to repeat the previuos character or character class as often as possible.
来源:https://stackoverflow.com/questions/11847147/how-can-i-replace-html-code-in-notepad-using-regex