Regex isMatch Issue, Unable to make it work

I have a regex, but i am not able to use in isMatch activity, Am i doing anything wrong:
Color is the word i am searching for
Var MyWord=“Color”
(?<=Title=“[^”])\b+MyWord+\b(?=[^"]")

Hi @hansen_Lobo ,

Could you let us know if you have verified it in one of the Regex Testing sites ?

If not, Could you provide us with the Sample data and the data that you want to match. We could check it out in the below regex testing portal :

Then correct it as needed.

Hi @hansen_Lobo

Try the below regex expression

(?<=“).*(?=”)

Regards

The sample data. i used https://regexr.com/

<TocEntry
      Title="Color" - Highlight this text Color
Title=["Color"] - Ignore  this text Color
      Link="/Content/Color/" - ignore this text Color
      BreakType="Color" - ignore this text Color
      StartSection="false"
      PageNumberReset="Color"> - ignore this text Color
</TocEntry>
<TocEntry
      Title="Colord"> - ignore this text Colord
      //there could be Link="abc", BreakType="abc" here aswell
</TocEntry>
<TocEntry
      Title="dColord"> - ignore this text dColord
</TocEntry>

<TocEntry
      Title="my fav Color is red"> - Highlight this text Color
Title=["my fav Color is red"]> -  - ignore this text Color
</TocEntry>
<TocEntry
      Title="my fav 
Color 
is red"> - Highlight this text Color
</TocEntry>

@hansen_Lobo ,

Could you try with the below Expression :

"(?<=Title="")"+MyWord+"(?="")"

image

Unable to match with all the conditions

@hansen_Lobo ,

Could you let us know what do you mean by this ? Do you have varying data ?

If so, we need to understand how does the data vary from the data provided above.

Here are 3 conditions:

  • I need to replace text only if its inside Title=“The serach term here can be selected”.

  • I dont want to replace text within square brackets inside Title=[“The text here no replacing”]

  • The word should exactly match the term.

@hansen_Lobo ,

Could you verify back whether the given data is correct ? Is the Square Bracket before the Double Quotes, if so then the Provided Regex should work fine and replace only words starting from double quotes.

Title=“Color” - Highlight this text Color
Title=[“Color”] - Ignore this text Color
Title=“A red Color bus”- Highlight this text Color
Title=“A red Colored bus” -Ignore this text Color
Variable="A red Color bus "-Ignore this text Color since not Title=

@hansen_Lobo ,

Not so sure if we are fully understanding the requirement. Do check the below match :

image

The word Color in line 3 doesn’t Highlight

Hi @hansen_Lobo

Try the below regex expression

Highlight

Hope it helps !!

@hansen_Lobo ,

Could you check with the modified Regex Expression below :

(?<=Title="".*)\bColor\b(?=.*"")

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