Reputation: 35
I am trying to convert this line from Perl to python:
$line =~ s/$alwayssep/ $& /g;
Any ideas how this might be done in python?
Upvotes: 0
Views: 94
Reputation: 623
My Pythonizer converts that to this:
line = re.sub(re.compile(alwayssep),r' \g<0> ',line,count=0)
Upvotes: 1
Reputation: 16711
In Python, do the following where alwayssep
is the expression and line
is the passed string:
line = re.sub(alwayssep, r' \g<0> ', line)
Upvotes: 3