Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

variable in regex python

import re
s = 'I love books'
var_name = 'love'
result = re.search('(.+)'+var_name+'(.+)',s)
print result
var_name = 'hate'
s2 = 'I hate books'
result = re.search('(.+)'+var_name+'(.+)',s2)
print result
Source by www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #variable #regex #python
ADD COMMENT
Topic
Name
7+7 =