What is the usage of match and ismatch

I use ismatch activity to check whether string is same as my pattern and it returns boolean type of true or false.

But for match activity, what is the usage of match activity?

I want to extract some string in my pattern. Can I use match activity to help me for that?

2 Likes

Hi @Emily_Yip

Yes you can use match activity to check whether the regex pattern matches based on the string

Thanks
Ashwin.S

1 Like

You can use matches activity for that and you can practice your regex in below site,

1 Like

Hi,

Matches activity returns list of matched value.

For example, we can get value if there is some number which we don’t know its value in advance, like the following.

Input: “Amount: 1000 \r\n Tax 10\r\n”
Pattern: “\d+”

The result will be {“1000”,“10”} as IEnumerabel<Match> type

Regards,

1 Like

Hi @Emily_Yip

For your reference.

cheers :smiley:

Happy learning :smiley:

2 Likes

Thanks for all.

And I have a pattern like “You can get #00011200 xx; #00121300 xxxx”
I use ismatch to check if there is any “#(any 8 digits),(a space), (;)”.

I also want to extract string for the 8 digit and xx value.
How can I solve it?

Hi @Emily_Yip

Try this expression

\d.*\w{4}

Thanks
Ashwin.S

Hi,

Can you try the following settings?

Pattern : "(?<=#)\d{8}\s\w+(?=;)"

Matches activity returns list of matched value.

If you want to get value directly, the following helps you.

strResult = System.Text.RegularExpressions.Regex.Match(strData,"(?<=#)\d{8}\s\w+(?=;)").Value
(Use Assign Activity)

Regards,

Use below regex in matches activity,
“(?<=#)\d*\s*\w*”
You will get two groups of match,
1.“00011200 xx”
2.“00121300 xxxx”

what is the use of # in the code you provided

and also use of (?=;)