Reputation: 1455
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?
Upvotes: 3
Views: 256
Reputation: 9417
I think you're escaping too many things. regexp = src="http://s\.perros\.com/content/perros_com/imagenes/thumbs/\([^"]*\)"
, replacement = src="" class="class-\1"
Upvotes: 2