regex - get string in between with python -


looking way items in between tabs

\t_e\t1\t_ 

i need 1 in other cases longer string.

re.search("\t_e\t(.*)\t_", string).group(1) 

9 times out of 10 line returns string/value want not always, clear after underscore letter white space.

try making regex lazy adding ? character after *, so:

re.search("\t_e\t(.*?)\t_", string).group(1)                     ^ 

this makes .* match little possible until next \t (and prevents . eat \t).


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -