RegEx
James Kew
james.kew at btinternet.com
Thu May 16 03:26:48 EDT 2002
More information about the Python-list mailing list
Thu May 16 03:26:48 EDT 2002
- Previous message (by thread): RegEx
- Next message (by thread): RegEx
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"x" <jar at mminternet.com> wrote in message news:MPG.174a3c3e60a4607b98969a at news.mminternet.com... > no_parans = re.compile('(|)', count = 99) > scan_line = no_parans.sub(' ', scan_line) As an aside, that count=99 argument to re.compile does nothing. sub does take an optional count argument, but if omitted or zero sub replaces all occurrences. I quite like John's suggestion of a '[()]' regex as it makes it clearer that you are replacing characters. Or build a translation table: trans = string.maketrans('()', ' ') scan_line = scan_line.translate(trans) which would make it easier to add new character substitutions later should you need to. -- James Kew
- Previous message (by thread): RegEx
- Next message (by thread): RegEx
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list