Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Quick help with regular expressions
#1
Okay, here is my string I'm working with.

"Todd taught me to move towards upper right-hand side to attack and kill #bJr. Sentinel#k"

I want it to turn into this:

"Todd taught me to move towards upper right-hand side to attack and kill [noparse]Jr. Sentinel[/noparse]"

Here's how I'm currently doing it:

Regular expression --> #b[\w ]*#k
Then snip off the ends (#b and #k)
Then add my tags ([noparse] and [/noparse])
Then do a string replace("[noparse]Jr. Sentinel[/noparse]" for "#bJr. Sentinel#k")

There's got to be a faster, more efficient way of doing this in Python. Any ideas?
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)