I have this notational language for posting stuff on my blog and I use the following line to parse images
$$link_to_image width height alternative_description$$
I am parsing this with the following php sentence
preg_replace('/\$\$(.*?)\s\d+\s\d+\s(.*?)\$\$/','<img src = "\\1" width = "\\2px" height = "\\3px" alt = "\\4" >',$this->text);
where $this->text is the whole text of the blog's post.
the problem is when I enter something like
$$http://s15.postimg.org/60dod0gu3/input.png 400 300 Raw data$$
I am getting
<img src="http://s15.postimg.org/60dod0gu3/input.png" width="Raw datapx" height="px" alt="">
What is wrong with the regex I wrote ?
You only capture 2 groups but you want 4. Add two more capturing groups for the numbers:
\$\$(.*?)\s(\d+)\s(\d+)\s(.*?)\$\$
Demo.