I need help to come up with a regular expression for cleaning the aspx page entries.
....
Line 24: <asp:Button ID="id1" runat="server" meta:resourceKey="ButtonTxt"/>
Line 35: <asp:Label ID="id2" runat="server" meta:resourceKey="Name"></asp:Label>
Line 47: <asp:Label ID="id3" runat="server" meta:resourcekey="Other_Name"></asp:Label>
....
How do I write the regular expression to extract only meta:resourceKey="ButtonTxt"
, meta:resourceKey="Name"
, meta:resourcekey="Other_Name"
and so on. Basically I need to extract only the meta:resourcekey="xxxx"
strings.
I tried .*?(meta:.*?").*
but this gets only till the first "
.
You used the ?
qualifier to turn the *
-quantifier before the "
non-greedy (or "lazy"). This means it will match as little as possible with the given pattern. That is why this quantifier matches only until the first "
. The rest is covered by the .*
that follows your match group.
If you remove the ?
the *
-quantifier matches greedy (which is the default behavior). A greedy quantifier will match as much as possible, which in your case is the second "
.
You can see the difference here: https://regex101.com/r/IgA15K/1
And there is some documentation on the concept: https://learn.microsoft.com/en-us/dotnet/standard/base-types/quantifiers-in-regular-expressions#greedy-and-lazy-quantifiers