PHP / regex expert opinion needed
Community Forums/General Help/PHP / regex expert opinion needed| 
 | ||
| I would like to add a short cut so anyone that uploads to gallery can then use to place clickable full version of said gallery image into a post. But first, I was hoping to maybe "harden" up the youtube and new monkey tag handling first (which may or may not be postable in machine readable format on this host): 
     //	<youtube youtube_id>
	$text=preg_replace(
	";\[youtube(\s+)(.+?)\];is",
        "<iframe width=\"560\" height=\"345\" src=\"http://www.youtube.com/embed/$2\" frameborder=\"0\" allowfullscreen></iframe>"
        ,$text );
    //	<gallery id>
	$text=preg_replace(
	";\[gallery(\s+)(.+?)\];is",
        "<div>coming soon</div>"
        ,$text );
    //	<monkey iframe>
	$text=preg_replace(
	";\[monkey(\s+)(.+?)\];is",
		'<iframe src="http://apps.monkey-x.com/$2/1/html5/MonkeyGame.php?width=640&height=480" width="640" height="480" style="display:block;"></iframe>'
        ,$text );
 | 
| 
 | ||
| So you just append whatever is given as "second param: {monkey ../bad/worse/worst} Eg. use this: https://regex101.com/ to check your regex online. So for the monkey part: ";\[monkey(\s+)(\d+)\];is", might do. Regardless of that: I am not sure if it is a good idea to just "preg_replace" instead of replacing valid ones and erroring "post submission" on invalid ones. Here is for youtube: 
Format:
{youtube}https://www.youtube.com/watch?v=30Nm9mUKt2g{/video}
\{youtube\]([^\[<]*?)/(v/|watch\?v=)([^\[<]*?)\[/youtube\}
{youtube 30Nm9mUKt2g}description{/youtube}
\{youtube ([a-zA-Z0-9_]*)\](.*?)\[\/youtube\}
curly brackets by me to avoid auto-video-insertation which happens - EVEN IN THIS CODEBOX!!)
This is my suggestion, let's see what others say. Edit: PHP offers preg_replace_callback() to handle things individually. More important: video links in code-tags are converted to videos instead of being kept as raw links. Therefor on processing a post you need to split "content" from "code in {code}-tags" (code needs to stay untouched). Next to the things you are doing here: thought of replacing the forum with a lightweight solution (I am using fluxbb.com) which does that for you already? I know the forum was used in the past to bring together account credentials (registered products etc) and users. But with the things being free... just a thought. And if not: their "includes/parser.php" should help you regarding some bbcode and code-block extraction. bye Ron | 
| 
 | ||
| Thanks Ron, those modifications are exactly what I had in mind. The codebox thing would be nice to solve but we may need to take such discussion private. I am keen to make only small incremental changed to the site and have no interest in adapting any more third party craft. | 
| 
 | ||
| Ron, are you on LinkedIn? | 
| 
 | ||
| Nope, but emailed you some minutes ago. bye Ron | 
| 
 | ||
| Also: http://regexr.com/ http://www.regextester.com/ |