Hi team, I need help for Regex match

Hello team,

I need regex value of below these String
String =“Wo DAS C40\r\n<BACK\r\nMy\r\nGitcArDpS,\r\nUse cards in-store or digitally at checkout\r\nGIFT\r\n©\r\ncarn@ © |\r\n$120.00\r\n3\r\nal Lm\r\n2 . 2\r\n6000-1000-0150-4427\r\nJ Oo Oo”

in these string need two regex

first one is “120.00”
second one is “6000-1000-0150-4427”

note that values are dynamically changed.

kindly help me anyone for regex

Thank you in adavance

Hey @Mada_Sai_Krishna

  1. Monetary regex:
    \d+\.\d{2}

  2. Credit card number:
    \d{4}-\d{4}-\d{4}-\d{4}

1 Like

@Mada_Sai_Krishna

(?<=\$)\d+\.\d{2}

\d+\-\d+\-\d+\-\d+

Out1=System.Text.RegularExpressions.Regex.Match(Input,"(?<=\$)\d+\.\d{2}").Value
StrOut2=System.Text.RegularExpressions.Regex.Match(Input,"\d+\-\d+\-\d+\-\d+").Value

HI @Mada_Sai_Krishna

1st regex ---> (?<=\$)(\d+[.,]?\d*[.,]\d+)

2nd regex ---> (\d+\-\d+.*\-\d+)

Regards

@Mada_Sai_Krishna
First value
(?i)(?:$)?\s*(\d+(?:.\d+)?)\s*(?:GIFT)?
second value
(\d{4}-\d{3}-\d{3}-\d{4})

check with expression

Hi @Mada_Sai_Krishna

Regards,

For the first value:
Assign activity → YourVariableForAmount = System.Text.RegularExpressions.Regex.Match(YourInputString, “\d+.\d{2}”).Value

For the second value:
Assign activity → YourVariableForCardNumber = System.Text.RegularExpressions.Regex.Match(YourInputString, “\d{4}-\d{4}-\d{4}-\d{4}”).Value

Replace YourInputString with the variable that holds the string you want to search. The result will be a match object, from which you can get the .Value to obtain the matched string.

Hi @Mada_Sai_Krishna

System.Text.RegularExpressions.Regex.Match(Input,"(?<=\$)(\d+[.,]?\d*[.,]\d+)").Value.Trim() 

System.Text.RegularExpressions.Regex.Match(Input,"(\d+\-\d+.*\-\d+)").Value.Trim()

Regards

Hi @Mada_Sai_Krishna

\d+.\d{2}

\d{4}-\d{4}-\d{4}-\d{4}

Hope it will helps you :slight_smile:
Cheers!!