Reputation: 3267
I am using:
"<a\b[^>]*href=\"\\lyrics\\*\">(.*?)</a>";
And I'm trying to find the value under these paremeters:
<a href="/lyrics/anything.html">This is what I need</a>
I need to find the "This is what I need" but the "anything" changes depending on the link. I don't want to find the text inside all the 'a' tags but, only ones of which have are inside the lyrics folder. I can't see why this currently isn't working? I'm awful at explaining but thanks in advance. Oh and I understand regex perhaps isn't the best method but, I really want to look into it.
Upvotes: 0
Views: 67
Reputation: 499002
You are escaping \\
instead of using /
(it is /lyrics/
not \lyrics\
.
Additionally, \\*
will match 0 or more \
characters, when you should be matching on any character that is not "
.
The following will do:
"<a\b[^>]*href=\"/lyrics/[^\"]*\">(.*?)</a>"
Upvotes: 2
Reputation: 613
Depends on which RegEx engine you're using. Given a Perl or Java engine here's what I see wrong.
\b
is unnecessary
\\lyrics\\*
should be /lyrics/.*
(if Perl, then you'll need to escape the /
as well.)
Upvotes: 0
Reputation: 24410
Your slashes are the wrong way around (i.e. those which make up the path) and you're missing a dot before the *:
<a\b[^>]*href=\"/lyrics/.*\">(.*?)</a>
Upvotes: 0