Expression to remove spaces from string or fetch value from array!

Input string: “Amount $124.238”
After splitup!
Input array =

“Amount”
" "
" "
" "
“$124.238”

Index value is not fixed. Spaces may increase/decrease.
Question: How do I fetch value “$124.238” from the whole array

@nidhi.kowalli1

strinput.split({"Amount"},StringSplitOptions.RemoveEmptyEntries).Last.trim

You can try this

1 Like

Hi @nidhi.kowalli1

You can use the substring to get the desired results

str_Input.Substring(str_Input.IndexOf("$")).Trim

Hope this helps :slight_smile:

Input variable is of type " Ienumerable" from regex activity “Matches”.

It gives me Null value as output

Input variable is of type " Ienumerable" from regex activity “Matches”.

It gives me Null output

Hi @nidhi.kowalli1

Try this:
Input = "Amount $124.238"
Output = System.Text.RegularExpressions.Regex.Match(Input,"\$\d+[.,]\d+").Value.Trim()

Input = "Amount $124.238"
Output = Input.Split({" "c}, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(Function(x) x.StartsWith("$"))

Let me if you have any queries, I’m happy to help.

Regards

I think this is another question where you are using matches in the regex expression can you share the snip of your code where you are getting this error. If you use the code given by me or nikhil this error will not come

@nidhi.kowalli1

stroutput.Cast(of match).select(Function(a) a.ToString).where(Function(a) not string.IsNullOrEmpty(a.tostring)).last

you can use this and pass the output of matches variable in place of stroutput

Using this.
What if I have multiple name for key,
I.e " Amount" or Total Amount"

@nidhi.kowalli1

use this expression

system.Text.RegularExpressions.Regex.Match(strinput,"[$\d.]+").tostring.trim
1 Like

Thank you so much. Working Fine

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.