regex - Why doesn't the following regular expression work in Python? -


i have following code:

regularexpression = r'([-\w]*\w)? ?: ?([-"\#\w\s_]*\w?);' outputfr = re.findall(regularexpression, inputdata, re.ignorecase) return data 

it's supposed catch words, hyphens , other characters, ending in ";". so:

(hello-nine: hello, six, seven; hello-five: 6 eight) output [('hello-nine', 'hello, six, seven'), ('hello-five', 'six eight')

if final-number: "seventy", "sixty", "fifty", forty part of user input (inputdata), regularexpression doesn't catch it. i'd want output [('final-number', '"seventy", "sixty", "fifty", "forty")]

why this?

in regular expression, second group:

([-"\#\w\s_]*\w?) 

needs changed match commas:

([-"\#\w\s_,]*\w?) 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -