3

I was trying the replace-regexp command in Emacs but I've no idea about how to construct the right regexp. My file looks like the following:

<img src="http://s.perros.com/content/perros_com/imagenes/thumbs/1lundehund2.jpg" />
<img src="http://s.perros.com/content/perros_com/imagenes/thumbs/1pleon2.jpg" />

And I want to replace for:

<img src="" class="class-1lundehund2.jpg" />
<img src="" class="class-1pleon2.jpg" />

I was using this regexp with no success (Replaced 0 occurrences):

M-x replace-regexp
  Replace regexp:  src\=\"http\:\/\/s\.perros\.com\/content\/perros_com\/imagenes\/thumbs\/\([a-zA-Z0-9._-]+\)\"
  Replace regexp with: src\=\"\" class\=\"class-\1\"

But in re-builder mode with the same regexp (changing \([a-zA-Z0-9.-]+\) by \\([a-zA-Z0-9.-]+\\)) all the results are right highlighted. I've no idea of what's happening, any tip?

1 Answer 1

2

I think you're escaping too many things. regexp = src="http://s\.perros\.com/content/perros_com/imagenes/thumbs/\([^"]*\)", replacement = src="" class="class-\1"

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! it runs so well. You must be right, I was escaping lot of things, thanks again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.