[Solar-talk] Solar_Markdown_Plugin & preg_replace
Rodrigo Moraes
rodrigo.moraes at gmail.com
Mon Apr 30 07:39:06 PDT 2007
Hey,
Maybe a regexp expert can give me a help. I have a legacy code which
parses inline images using the a syntax like the following:
<%image(image_file.jpg|width|height|alt text)%>
Now I would like to use a Solar_Markdown_Plugin to parse it and start
using only Solar_Markdown for text parsing. I'm almost there. The
problem is to include < and > in the regexp.
The best I could get was this:
$text = preg_replace_callback('{
( # wrap whole match in $1
%image\(
(.*?) # href = $2
\|
(.*?) # width = $3
\|
(.*?) # height = $4
\|
(.*?) # title = $5
\)%
)
}xs',
array($this, '_parseInline'),
$text
);
Then for <%image(file.jpg|307|783|some text)%>, I get:
$1 = %image(file.jpg|307|783|some text)%
$2 = file.jpg
$3 = 307
$4 = 783
$5 = some text
So, I couldn't set up a regexp to also include < and > in the
replacement. :-| Can anybody help?
thanks,
rodrigo
More information about the solar-talk
mailing list