python - regex between some character -


input:

[1] string1 [2] string 2[3]string3 [5]string4 

output:

string1 string 2 string 4 

how resolve case "input" , result "output" "regex" python?

your instructions bit vague, said - using example input provided:

import re line = '[1] string1 [2] string 2[3]string3 [5]string4' matches = re.match(r'\[1\] (.*?)\[2\] (.*?)\[3\](.*?)\[5\](.*)', line)  print matches.group(1) # prints string1 print matches.group(2) # prints string 2 print matches.group(3) # prints string3  print matches.group(4) # prints string4 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -