Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Quick help with regular expressions
#3
import re
re.sub(#b([\w ]+)#k,$1,string)

etc. I'm not sure if you need to escape the [] in the replacement string cause I tested it using some online thingy. And I don't know if \w will match a "." which is in Jr. Sentinel. Might just want [.]

Brackets() let you refer to each match by $1, consecutive brackets are $2 etc. like if you look for (#[br])([\w ]*)#[kb] then $1 would be a b, $2 the "Jr. Sentinel".
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)