How to make a proper Regex -


i have think simple question on making regex. here's string:

  confl 2284341         /folder/path/file.xlsx 

i want make sure line has "confl" in it, , want capture full path. came is:

.*confl .*(\/.+) 

but captures file name, not full path (i can live not getting initial forward slash). seemed straight forward, is regex, so...

anyone me out?

thanks!

change

.*confl .*(\/.+) 

to

.*confl .*?(/.+) 

this prevent middle .* being "greedy" , capturing last slash. instead, question-mark makes "possessive", stops before first slash, goal.

unless there i'm misunderstanding, don't need escape slash before up-right slash, i've removed.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -