Breaking News

Extract Digits from the text line

Q:

I've a use case where in i wanted to extract digits from the below sample text. Can someone help me to resolve this?

"CDH Investments Join $14.5M Round In Chinese Online Education Firm Longzhimen"



A:

I would suggest regexp, unless text around the number is static - then just replace "CDH Investments Join $" and "M Round In Chinese Online Education Firm Longzhimen" with "" and you have your digits.


A:


Store this in data Item. Now use the calculation stage and use Length function store it in data item now take 2nd calculation stage and find the position of "$" using Instr function and store in data item again use calculation stage use Instr function and expression should be "Total Length of string", Total Length of string - Postion length.

A:

text is not static hence replace would not work,
Can you please share Regex Pattern to extract "14.5" for the said string?

A:
I tried your suggestion and it will work for $ cases but the currency is not static and will chance form case to case.

A:
Simple one is: "[\d\.]+" (that will match something like 127.0.0.1 too if it happens to be in input), "\d+(\.\d+)?" is better to match float.
Seems like you don't care about M suffix... 

Final Answer is:

It works with small ticks.
"([$](\d+)([.]*)[\d*])"

No comments