Answer the question
In order to leave comments, you need to log in
How to remember regular expressions in python3?
Let's say in php I want to add an @ sign to all words, then I write like this:
echo preg_replace('#(\w+)#si', '\@\\1', 'text text text');
Answer the question
In order to leave comments, you need to log in
Parentheses will help you, the code example is quick:
>>> import re
>>> re.sub(r"(\w+)", "@\\1", "This is a test")
'@This @is @a @test'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question