How to create an exact match for a string using isMatch

Hi,

How to match an exact string in a Text content , i am using the below api. It matches strings containing the given string.
Example:
If the String to be found in the Text content is “Type”, it returns true even if it finds “Type” in “Typewriter” it should match only “Type” in the content,

row(2).ToString is the string to be found in the PDFContent.(Text Content)

System.Text.RegularExpressions.Regex.IsMatch(PDFContent,row(2).ToString)

Tried giving as below:

System.Text.RegularExpressions.Regex.IsMatch(PDFContent,^row(2).ToString$)

it generates error in the If activity.

Is there a method to find an exact match of the string using IsMatch

@mailsmithash
You Can try this-
For single Result
System.Text.RegularExpressions.Regex.Match("yourstring,“string to be found”).ToString

For Multiple Results
System.Text.RegularExpressions.Regex.Matches("yourstring,“string to be found”).ToString

The Match api does not return a Boolean value, i am using the isMatches in an If Condition. But apparently it it returning true even if that string is found as substring in other strings.

U can try String.contains() in If activity.

Yes i have tried String.Contains() that too works in the same manner as isMatch, returns true, if the matched string is a substring of other string.

Try with this Regex expression :

" \b keyword \b "

2 Likes

Thanks its working now, for the exact match.

System.Text.RegularExpressions.Regex.IsMatch(PDFContent,“\b”+row(2).ToString+“\b”)

This is working for finding the exact String match.

I’m glad that helped. If you could mark that as a solution i would be grateful

1 Like

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