cancel
Showing results for 
Search instead for 
Did you mean: 

Extract Digits from the text line

RushitVaghasiya
Level 3
Hello, 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"   Thanks,
8 REPLIES 8

AndreyKudinov
Level 10
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.

Anonymous
Not applicable
CDH Investments Join $14.5M Round In Chinese Online Education Firm Longzhimen --> 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. I hope this will help.

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

RushitVaghasiya
Level 3
@Saumitra I tried your suggestion and it will work for $ cases but the currency is not static and will chance form case to case.

AndreyKudinov
Level 10
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...   

RushitVaghasiya
Level 3
Thanks aikudino It works with small ticks. ""([$](\d+)([.]*)[\d*])

Hi, could you please explain how did it work? I have the same usecase as below and need to extract 2.65 and then 8 etc., This text is in collection

Deducted amount 2345 as of 28/03/22 for rate 2.65 per scheme
Deducted amount 678 as of  8/02/22 for rate nxy 8 per scheme

------------------------------
Navaneetha Thupalli
------------------------------

Hi N,

If your search this community for 'regex' threads, you'll find a lot of examples and instructions on how to accomplish that. There's also this site to help you further with regex.

------------------------------
Happy coding!
Paul
Sweden
------------------------------
Happy coding!
Paul, Sweden
(By all means, do not mark this as the best answer!)