Jump to content

Regex for spoiler tag


eevan79

Recommended Posts

Here is my code for spoiler tag:

$search:

'/\[spoiler\][\r\n]*(.+?)\[\/spoiler\][\r\n]*/si',

 

$replace:

'<div class="spoiler"><input type="button" onclick="showSpoiler(this);" value="Show/Hide" /><div class="inner" style="display:none;">$1</div></div>');

 

Now I want to reverse back html code to [ spoiler ] text [ / spoiler ]

 

Here is my code, but its not working

 

$search

'/<div class="spoiler"><input type="button" onclick="showSpoiler(this);" value="Show/Hide" /><div class="inner" style="display:none;">(.+?)<\/div><\/div>/is'

$replace

'
[spoiler]\\1[/spoiler]
'

 

Can somebody help me to get this HTML to spoiler bbcode?

Link to comment
https://forums.phpfreaks.com/topic/211350-regex-for-spoiler-tag/
Share on other sites

So far I have tried following code:

$search = array(
'/<div class="spoiler"><input type="button" onclick="showSpoiler(this);" value="Show\/Hide" \/><div class="inner" style="display:none;">(.+?)<\/div><\/div>/is'
);

$replace = array(
'
[spoiler]\\1[/spoiler]
'
);

 

But it does not working. What I am doing wrong...?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.