billy_111 — 2011-10-17T03:46:42-04:00 — #1
I am having a problem with some Regex and i don't know how to fix. Take a look at the following code:
if (Regex.IsMatch(input, "<[aA].*xlink:href.*>.*</[Aa]>"))
Now, there is other code with this conditional statement but it's not relevant as to what i am having problems with. This code checks for an a href link. I have 2 instances of links:
<a title="Meet the Team" xlink:href="tcm:12-1451" xlink:title="Meet the Team">Meet the Team</a>
<a title="Meet the Team" href="tcm:8-1451">Meet the Team</a>
The top one works fine, but the bottom one does not because it doesn't have the "xlink" appended at the start. Does anyone know how i can change the regex so that it matches both?
jason__c — 2011-10-17T15:34:19-04:00 — #2
Not a guru of RE, someone lese can help you there, but why are you using XLink?
mittineague — 2011-10-17T22:47:34-04:00 — #3
I don't know if .NET uses Perl flavor regex, but if so try putting the "sometimes threre sometimes not" inside parentheses followed by a question mark (i.e. 0 or 1 occurences)
imaginekitty — 2011-10-17T23:08:21-04:00 — #4