How to use Contains Help

Hi,

i would like to Get Data with the character is abc and number is 10 digits.
Ex
-“abc0123456789”- True
-“abc 0123456789”- True
-“abc012-3456-789”- True
-“abc0123456”- False
-“aa0123456789” - False

How to use Contains Or do you have any other advice?

Hi @punnipah
use the regex for this, that would be good

adding the code for extracting the data

assume the string which is used as input is stored in input1 variable

use assign activity

output1= System.Text.RegularExpressions.Regex.Match(input1,“abc\d{10}”).Value.ToString

You can also use the matches activity for this as well

Thanks & Regards,
Nived N

4 Likes

If you want to match 10 digits with space or hyphen in between also, change the regular expression to:

abc([ -]*\d){10}

image

2 Likes

Out put : is empty

My Process Read Subject E-mail and i would like to Get Data with the character and number is 10 digits.

Out put : invalid result

You need to use Regex function with the regular expression. E.g. change the if condition to:

System.Text.RegularExpressions.Regex.IsMatch(item.Subject.ToString, "CA([ -]*\d){10}")

We can go for the following strategy. Extract more and evaluate:

a digit length restriction can fail:
grafik
vs.

1 Like

What is CA and can you please explain about the given regex expression

CA is just the literal string “CA”. It’s from @punnipah screenshot:
image

The expression is as follow.
CA - match a string that starts med “CA”.
([ -]*\d) - match any number space or hyphen followed by one digit
{10} - match the previous condition ten times

Now to avoid the false positive @ppr mentioned you could also add (?=\D|$), telling it to only match if the next character after the ten digits, is a non-digit or the end of string.

CA([ -]*\d){10}(?=\D|$)

image

1 Like

Got it but above string start from abc

Yes, that’s correct. “abc” is probably just an example that punnipah provided. I’m pretty sure the real input string doesn’t actually contains “abc”.

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