954,576 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problem with Regular Expressions

Hello everyone.

I am working on this forum/post/script type thing.
What I want to do is convert this example to HTML.

[div]
[p]Some text[/]
[div]
Some more text
[/]
[/]

--->

Some text




Some more text

I don't want to use [/div] or [/p] to keep it short, but that is the problem where I get stuck.
This is what I've tried, it doesn't work:

$string = preg_replace('/\[div\](.*)\[/\]/s', '\\1', $string);

Please help!

RoyalElite96
Light Poster
44 posts since Dec 2010
Reputation Points: 16
Solved Threads: 2
 

Escape forward slash.

.. *)\[\/\]/s', '<div>\\1</div>', $string);

Hope this would help you to carry on.

kekkaishi
Junior Poster
164 posts since Oct 2009
Reputation Points: 28
Solved Threads: 37
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: