### Post

2 followers Follow # How to extract Numbers from String?

For Example

In my Comment field I will get a comment from our Team leaders stating like “Team Strength = 15 Nos “

I want to take this 15 from above string and planning to use for my Calculation

I have used some codes from supports but it hasn’t worked for me.

Ravikishan Bhat Hi Ravikishan,

in this use case where there is only one number ("15") in the text:
@comment field.replace(/[^0-9]/g,"")
That replaces everything but digits.
If the format is always the same, e.g = followed by the number you can also use:
@comment field.split("= ").pop().split(" ").shift()

Both ways return 15 - but it's technically a string (text) not a number, you can't calculate with it, e.g. that 15 plus 1 will return 151, not 16. You must parse it to a number first:

`Number(@comment field.replace(/[^0-9]/g,"")) || 0`

Rainer   Hi Rainer

I used your suggestion as per attached screen shot result I got " 0" Always Please check

I want to get 15 as output in this example  Hi Rainer

I tried following formula as well but it wont worked

str = @Member Count.replace(/(<.*>)|( )/g,"").replace(/( )|([_\n\r\*\\])|(&nbsp;)/g, " ");

Number(str. replace(0 ||/[^0.9]/g,"")) Sorry, I had a typo in my code
must be [^0-9] not [^0.9] (don't know why it had a dot in it)

`Number(@Member Count.replace(/[^0-9]/g,"")) || 0`

But

`Number(@Member Count.split("= ").pop().split(" ").shift())`

should work too.

str = @Member Count.replace(/(<.*>)|( )/g,"").replace(/( )|([_\n\r\*\\])|(&nbsp;)/g, " ");
Number(str. replace(0 ||/[^0.9]/g,""))
doesn't make any sense.

Rainer Hi Rainer,

I tried this code as well but Result is "0"

var Can= (str = @comment Filed.replace(/(<.*>)|( )/g,"").replace(/( )|([_\n\r\*\\])|(&nbsp;)/g, " "));

var Van = Number(Can.replace(/[^0.9]/g,"")) || 0;

Van; `Number(@Member Count.replace(/[^0-9]/g,"")) || 0This Code Worked for Me Thanks a lot `