Using regex how do you extract a number following a string? (the output should be just the number) -


how using regex?

example input: this sentence 1234 bunch of other stuff.

output: 1234.

i know if this: (?<=this sentence).\d\d\d\d can replace 4 digit number anything. want opposite: want replace except match something, in case nothing (ie "").

use replace with

\d 

as regex , "" being replace matched terms with.

\d means numeric character.

\d means non-numeric character.

edit: since seem need literal regex... i'd run 2 replaces, first remove before number, , second remove after number.

first = replace("this sentence 1234 bunch of other stuff",".*[tt]his sentence (?=1234)","") second = replace(first,"\d+.*","") 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -