I am developing a simple XHTML BBCode text editor as part of a project.
Most BBcode wont allow you to add attributes such as class, id, title.
Unfortunately my regular expression skills are very limited, so I am hoping someone can help.
This is examples of the code I would like to match
1. [img=sdfgsd] 2. [img=sdfgsd id=test] 3. [img=/sdfgsd/test/tes.htm id=testme ] 4. [img =sgsgrf.gif id=test title=test class=test]Most of this I have been able to match, it just gets tricky when you have more then 1 attribute (id, class, title) like in eg 4.
Currently I have
/\\[\s*img=\s*(\w*[\/?\w*]*\.?\w*)?\s*( (id=|class=|alt=|title=)(\w*)*?)\s*\\]/Once I can match more attributes I will need to be able to backreference them and add them to the replaced text to create an img tag.
Any help, ideas or suggestions appreciated.