tags:

views:

41

answers:

3

I am trying to convert this:

[img,src=http://www.ANYTHINGHERE.com/image.png,width=55px,height=105px]<br />

To this:

<img src="http://www.ANYTHINGHERE.com/image.png" width=55px height=105px>

(without spaces)
I am trying with this regex:

/(\[img[| |,|]?[(src=(.*)?)|(width=(.*)?)|(height=(.*)?)|,]*)(\])/<br />

But it doesn't find the tag

A: 

You'll need to escape a lot of those characters.

EDIT: Now looking at your actual regex, the problem is the character class in the middle. You realize character classes are only for alternations of individual characters, right?

Anon.
So how can I do that for a lot of characters?
M28
+1  A: 

I might add there are lots of resources to test regex, like this Regex Tester, which gives you real time feedback to how your regex is matching.

Matt
+2  A: 

The regex without escaping:

[([a-z]+?),([a-z]+?)=([^,]+),([a-z]+?)=([^,]+),([a-z]+?)=([^,]+)]

and replace in pseudocode:

<$1 $2="$3" $4="$5" $6="$7">
mkotechno