Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Quick help with regular expressions
#2
replace [noparse]/#b([\w ])#k/ with /\Q\E\1\Q/.[/noparse]

Does Python have a substitution function?

sed/anything similar = [noparse]s/#b([\w ])#k/\Q\E\1\Q/g;[/noparse]
Actually I guess that should be [noparse]s:#b(.*?)#k:\1:g[/noparse] which looks much nicer.

Explanation: \Q starts a literal string, \E ends it. When you place a segment of a regex in parentheses it gets stored in the buffers \1..\9.
Reply


Messages In This Thread
Quick help with regular expressions - by Fiel - 2009-07-06, 01:56 PM
Quick help with regular expressions - by Dusk - 2009-07-06, 02:25 PM
Quick help with regular expressions - by Stereo - 2009-07-06, 02:34 PM
Quick help with regular expressions - by Dusk - 2009-07-06, 02:39 PM
Quick help with regular expressions - by Nikkey - 2009-07-06, 02:45 PM
Quick help with regular expressions - by Fiel - 2009-07-06, 03:12 PM
Quick help with regular expressions - by Nikkey - 2009-07-06, 03:22 PM
Quick help with regular expressions - by Fiel - 2009-07-06, 03:45 PM
Quick help with regular expressions - by Stereo - 2009-07-07, 12:30 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)