Example:
Regular Expression:
\[ppp=(.*?)\](.*?)\[/ppp\]
Replacement:
<span title="$1" class="classz">$2</span>
If a user post like this:
[ppp=test "with" title]some text[/ppp]
Html out:
<span title="test "with" title" class="classz">some text</span>
So i want any
" or
' characters got removed from $1 output.
Is this possible?
I don't understand what you mean. Can you give an example ?
I don't think it's possible to do this with MyCode, the better way is to have a plugin to clean the content of the tag and return the formated content.
<?php
if(!defined('IN_MYBB'))
{
die("This file cannot be accessed");
}
$plugins->add_hook("parse_message", "ppp_run");
function ppp_info () {
return array (
"name" => "PPP test",
"description" => "Adds ppp tag",
'website' => 'http://community.mybb.com/mods.php?action=profile&uid=6880',
"author" => "CrazyCat",
'authorsite' => 'http://community.mybb.com/mods.php?action=profile&uid=6880',
"version" => "1.0",
"compatibility" => "18*",
"codename" => "ppp"
);
}
function ppp_activate () {
}
function ppp_deactivate () {
}
function ppp_run ($message) {
return preg_replace_callback('#\[ppp=(.*?)\](.*?)\[\/ppp\]#ims', 'ppp_replace', $message);
}
function ppp_replace($matches) {
$matches[1] = str_replace(['"', '\''], '', $matches[1]);
return '<span title="'. $matches[1].'" class="classz">'.$matches[2].'</span>';
}
Thank you, but it seems not working.
Update:
Sorry. it's working. just need to disable ppp MyCode.
Works on my dev forum, can you provide an url and a test account ?
And as I don't think you really use the "ppp" tag, the real source of your plugin (which is activated ???)
I tested on MyBB 1.8.27 with MyCode of post #1 (with ppp tag) and your plugin. (unchanged)
I try again tomorrow.
Sorry. it's working. just need to disable ppp MyCode.
Thanks again
Another approach would be to use a RegEx that doesn't accept quotes at all.
Very good friend, thank you very much.