Regexp.escape the href values

Hi All,

    I want the skip the href values which is inside , while doing rake
task. but i am getting out put like this.

my text = <a href="Rails">rails</a>

Rails is the keyword, but if already got linked, it should not link
again.

but i am getting output like this.

<a href="<a href="http://localhost/dest/rails">Rails</a>">rails</a>

its linking inside again.

for this i have used the Regexp.escape. but its not working as expected.

def match_string(s)
        /(#{Regexp.escape(s)})(?!([^(<a)]*<\/a>)|(\/)|\w)/
end

So, Please advise me, if anyone knows ASAP.

This rather muddled. You haven't really explained what the input is,
what the expected output is and exactly what that regular expression
is trying to match

Fred

Hi Fred,

    Thanks for your reply.
My input will be:

     "The lion is the largest African carnivore. It is a sandy to tawny
coloured cat with white under parts on which females often retain
rosettes and spots characteristic of younger animal.then the last one is
<a href="Tiger">test</a>

The keywords are : lion, animals, african, Tiger.

So my expected output are , when i am running the task , should be
linked the keywords with href. but except which is in href already.

Expected Output:

"The <a href="www.animal.com">lion</a> is the largest <a
href="www.animal.com">African</a> carnivore. It is a sandy to tawny
coloured cat with white under parts on which females often retain
rosettes and spots characteristic of younger <a
href="www.animal.com">animal</a>.then the last one is <a
href="Tiger">test</a>

But right now i am getting like:

"The <a href="www.animal.com">lion</a> is the largest <a
href="www.animal.com">African</a> carnivore. It is a sandy to tawny
coloured cat with white under parts on which females often retain
rosettes and spots characteristic of younger <a
href="www.animal.com">animal</a>.then the last one is <a href="<a
href="www.animal.com">Tiger</a>">test</a>

Note: See i am getting link twice , inside the href again and again.

it should not link , which is inside the href.

I hope u understand now.

Frederick Cheung wrote:

"The <a href="www.animal.com">lion</a> is the largest <a
href="www.animal.com">African</a> carnivore. It is a sandy to tawny
coloured cat with white under parts on which females often retain
rosettes and spots characteristic of younger <a
href="www.animal.com">animal</a>.then the last one is <a href="<a
href="www.animal.com">Tiger</a>">test</a>

Note: See i am getting link twice , inside the href again and again.

it should not link , which is inside the href.

that makes sense, what doesn't make any sense is your regular
expression. What were you trying to make it do?

Fred

Linker should ignore keywords inside of hyperlinks

Example:

  <a href="Animal">Tiger</a> is a animal.

This text should be not link which is inside link tag.

<a href="Animal">Tiger</a> is a <a href="Animal">animal</a>.

But right now i am getting like

<a href="<a href="Animal">animal</a>Animal">Tiger</a> is a <a
href="Animal">animal</a>.

Does it make sense?

Frederick Cheung wrote:

Linker should ignore keywords inside of hyperlinks

Example:

<a href="Animal">Tiger</a> is a animal.

This text should be not link which is inside link tag.

<a href="Animal">Tiger</a> is a <a href="Animal">animal</a>.

But right now i am getting like

<a href="<a href="Animal">animal</a>Animal">Tiger</a> is a <a
href="Animal">animal</a>.

I got that first time round. What i don't know is how you're trying to
use that regular expression. a little more of your code would clarify
matters.

Fred