Using RegEx to Validate Excel

I wanted to use the RegEx " ([\w\d]{4}.[\w\d]{6}|[\w\d]{10}|[\w\d]{6}) " to validate the file how can I do it as i Couldnot use the whole regex to achieve the result. Instead, I have to use
[\w\d]{4}.[\w\d]{6}” to attain result.
Please Help as it is quite urgent.
Thank you

Hi Nithi ,

Can you tell what exactly you are trying to match with the regex ?

Actually, My Excel contains some Value (Docket Number) which should be according to regEx eg. it may be something like P3U4.F65HE7 this is the value which I have to check whether it is exact according to regex.

HI Nitin,

I can see the first regex is working properly .

You need to use IsMatchActivity to validate and the output will return a boolean .

I tried the same for this I203.P17833US but it also got true as result.

also i am using system.Text.RegularExpressions.Regex.Match(row1(32).ToString,“[\w\d]{4}.[\w\d]{6}”).Success inside if condition for now but it will only check only for length 6. Please tell me how can I use system.Text.RegularExpressions.Regex.Match(row1(32).ToString,“[\w\d]{4}.[\w\d]{10}”).Success in the same if statement for checking 10 characters after (.).
Thank You

Check this below code, @Nitin_Tiwari
BooleanVariable = System.Text.RegularExpressions.Regex.IsMatch(“P3U4.F65HE7”,“[A-z0-9]+?.[A-z]{1}[0-9]{2}[A-z]{2}\d{1}”)
Hope this may help you :slight_smile:

This is working for given combination but I have also to check for P3U4.F65H879TE7 i.e. it can have 10 character after (.)

BooleanVariable = System.Text.RegularExpressions.Regex.IsMatch(“P3U4.F65HE7”,“[A-z0-9]+?.[A-z]{1}[0-9]{2}[A-z]{2}\d{1}”)

If I have to explain it more clearly, I want a Regex which can count Characters after dot (.) in the value and that count is either 6 or 10. e.g. P3U4.F65HE7 this value can be validated as it has 4 word before dot and 6 value after dot. on the other hand if i write P3U4.F65HE7Y it must not get valdated although it has 4 value before dot but after dot it has 7 characters.
Thank you

@Nitin_Tiwari - is it ok, if we use .length to find if its 6 or 10…

StrOutput is matchCollection

Write Line = StrOutput(0).groups(1).ToString.Length.ToString

Update: if you want to validate the before dot for 4 chars we can try this too…

Note: This can be also achieved using yourstring.split(".“c)(0) – before dot AND
yourstring.split(”."c)(1) after dot