Regex is match OR condition in a single line?

How do we create an OR condition in regex where in it should return true either of the condition is met for example

System.Text.RegularExpressions.Regex.IsMatch(data,"^sampleregexhere1") | System.Text.RegularExpressions.Regex.IsMatch(data,"^sampleregexhere2")

if any of the following is met it should only return 1 value which either true or false. Is that possible ? Thanks

1 Like

Any idea ? Thanks.

regex = “pattern1|pattern2”

would that work in an IsMatch?

yes it should

no its not I tried

System.Text.RegularExpressions.Regex.IsMatch(data,"^sampleregexhere1") | System.Text.RegularExpressions.Regex.IsMatch(data,"^sampleregexhere2")

@Nathan - Are you looking something like this??

image

2 Likes

yeah but result is boolean @prasath17

2 regex expression

using System.Text.RegularExpressions.Regex.IsMatch

@Nathan - please give your sample text with variation and the expected result…

2 Likes

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