Replace String using Regular Expression {.*}

Python re.sub method:
>>> import re
>>> re.sub('.*', 'bar', 'foo')

Tcl regsub command:
% regsub -all {.*} foo bar

I feel the result of the Tcl expression is a little bit strange. If the regex was {^.*} or {^.*$}, the expression returns bar, but {.*$} returns the same result above - barbar.
How do you think about it?

Anyway, FME seems to be using Tcl regsub command internally for string replacement operations in some parts. e.g. StringReplacer (Use Regular Expressions: yes), BulkAttributeRenamer (Action: Regular Expression Replace), etc.
Maybe we will have to check carefully the replacing result with {.*}, especially in FME 2015.

No comments:

Post a Comment