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

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

Android Gson.fromJson error -