python/regex question... hope someone can help

charonzen your.master at gmail.com
Sun Dec 9 02:13:50 EST 2007


I have a list of strings.  These strings are previously selected
bigrams with underscores between them ('and_the', 'nothing_given', and
so on).  I need to write a regex that will read another text string
that this list was derived from and replace selections in this text
string with those from my list.  So in my text string, '... and the...
' becomes ' ... and_the...'.   I can't figure out how to manipulate

re.sub(r'([a-z]*) ([a-z]*)', r'(????)', textstring)

Any suggestions?

Thank you if you can help!



More information about the Python-list mailing list