I am having a problem finding the correct match for all the cases.
I want to catch something string( here in my example ##xyx##) which is in the quotes for example,
if i have something like
Case 1)
<picture href="hello" ##xyz##>##xyz##</picture>
the output should be no match found as none of them are in quotes.
if i have a different case something like
case 2)
<picture href="##xyz##" dbhdfbhg="dbfdhfbhgbt fgkg ##xyz## hdjvffhgfhd">
i want to match both the cases which have ##xyz## as both of them are in quotes
case 3)
<picture href="##xyz##">
##xyz##
</picture>
the regular expression should only catch the teh first one but not the second one ..
i have tried something like (“)([^”].)?(##xyz##)([^”].)?(“)
which gets the wrong output.
in the case 3 its catching the second one even though i use multiline option in regex. can some one help?
I am using C# for coding
You could try something like the following LINQPad snippet. The regular expression uses a lookahead
(?=to find a matching quote and then tries to match ##xyz## within that text segment:This gives the following correct output (i.e. two matches in first string and only one match in second):