Page 1 of 1

search and replace with regular expressions

Posted: Tue Jul 03, 2007 1:43 pm
by superdez
How could I replace all the commas with "commas followed by a space" only within the keywords meta tag ? (using dreamweaver's regular expressions)

Turn this:

<meta name="Keywords" content="word1,word2,word3,word4,word5,word6" />

into this:

<meta name="Keywords" content="word1, word2, word3, word4, word5, word6" />


I've tried many combinations but couldn't find answer:
"Keywords" content="[,]/>$

Posted: Tue Jul 03, 2007 3:22 pm
by feyd
What regular expression engine does Dreamweaver use?

Posted: Tue Jul 03, 2007 3:42 pm
by superdez
Adobe says that it uses the JavaScript engine.

Posted: Tue Jul 03, 2007 3:51 pm
by feyd
I'm not sure how complex you can make the expression(s) or code, but in Javascript (as well as PHP) what I do is write an expression to find the whole tag I want to manipulate first. I then iterate those results finding all "content" attributes. It's a simple replace call after that and some join method calls, typically.

Posted: Tue Jul 03, 2007 3:53 pm
by superdezign
Just copy the tag into a temporary file, do a regular find and replace on it, then paste it back.

Edit: 8O Do my eyes deceive me?