How to extract effective data

Hi all,

I used some processing to get a set of strings, as shown below:

  1           3.7 KGS        3.097 KGS     0.056

I want get the value 3.7 and 3.097 and 0.056, so how to do it, please help, thank you.

Hey!

Try this:

System.Text.RegularExpressions.RegEx.Match(StrInputVariable,"\d{1,}.\d{1,9}").ToString

Reference:

Regards,
NaNi

assuming txt = your string

System.text.regularexpressions.regex.match(txt, "([\d\.]+)\sKGS[\s]+([\d\.]+)\sKGS[\s]+([\d\.]+)").Groups(1).value

will give 3.7

System.text.regularexpressions.regex.match(txt, "([\d\.]+)\sKGS[\s]+([\d\.]+)\sKGS[\s]+([\d\.]+)").Groups(2).value

will give 3.097

System.text.regularexpressions.regex.match(txt, "([\d\.]+)\sKGS[\s]+([\d\.]+)\sKGS[\s]+([\d\.]+)").Groups(3).value

will give 0.056

@Chen-Jim

Hello Jack,
Thanks for your reply! Your answer is very helpful to me.
And I have another strings want to extract, please help.

 44       3,856.0 KGS    2,741.814 KGS    84.552
1 Like

Hey!

Try the above expression even if the changes in data the mentioned expression will work…

Regards,
NaNi

Hi,
It was return one value…

Hi,

The following sample might help you.

Sample20220726-6.zip (2.5 KB)

Regards,

Hey!

How about the following?

System.Text.RegularExpressions.RegEx.Match(StrInputVariable,"[0-9].[0-9].\d+.[0-9]+|[0-9].[0-9]+").ToString

Refrence:

StudioReference:

Output:

KGSOutput

Regards,
NaNi

@Chen-Jim

just update the regex to this (for all items)

([\d\,\.]+)\sKGS[\s]+([\,\d\.]+)\sKGS[\s]+([\,\d\.]+)