consider following string, table of content
table of content name abc ......... 20 name fghkjkj kjkj . 31 name.with.dot ..... 45
i want extract section's name 'name abc
' 'name fghkjkj kjkj
' , 'name.with.dot
'
i didn't found yet right regex achieve goal, insights?
i think following should work:
^.*?(?= \.+ \d+$)
assuming you're working line line or have multiline
mode enabled. positive lookahead assertion makes sure end match dots , number follow on line.
explanation:
^ # start of line .*? # match number of characters, few possible (?= # ahead assert following matches here: [ ] # space \.+ # 1 or more dots [ ] # space \d+ # number $ # end of line ) # end of lookahead
Comments
Post a Comment