I have a bunch of html with lines like this:
<a href="#" rel="this is a test">
I need to replace the spaces in the rel-attribute with underscores, but I’m sort of a regex-noob!
I’m using Textmate.
Can anyone help me?
/Jakob
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t think you can do this properly. Though I wonder why you need to do it at one go?
I can think of a really poor way of doing it, but even if I don’t recommend it, here goes:
You could sort of do it with the regex below. However, you would have to increase the number of captures and outputs with a _ on the end to the potential number of spaces in the rel. I bet that is a requirement which disallows this solution.
Search:
Replace:
This way has two downsides, one is there might be limitations to the number of captures you can have in Textmate, two is you’ll end up with a large number of _’s on the end of each line.
With your current test, with the regex above, you would end up with:
PS: This regex is of the format of the visual studio search/replace box. You’ll probably need to change some characters to make it fit textpad.