Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Simple Wiki Parser requires NOWIKI Tag
    text
    copied!<p>I've got a simple function that converts plain text into a wiki markup. But I faced a problem where I'm unable to prevent certain strings from modification. So I need additional <em>nowiki tag</em>, within which no changes are made. I'm not very familiar with regex so help will be appreciated.</p> <pre><code>&lt;?php function simpleText($text){ $text = preg_replace('/======(.*?)======/', '&lt;h5&gt;$1&lt;/h5&gt;', $text); $text = preg_replace('/=====(.*?)=====/', '&lt;h4&gt;$1&lt;/h4&gt;', $text); $text = preg_replace('/===(.*?)===/', '&lt;h3&gt;$1&lt;/h3&gt;', $text); $text = preg_replace('/==(.*?)==/', '&lt;h2&gt;$1&lt;/h2&gt;', $text); $text = preg_replace('/==(.*?)==/', '&lt;h1&gt;$1&lt;/h1&gt;', $text); $text = preg_replace("/\*\*(.*?)\*\*/", '&lt;b&gt;$1&lt;/b&gt;', $text); $text = preg_replace("/__(.*?)__/", '&lt;u&gt;$1&lt;/u&gt;', $text); $text = preg_replace("/\/\/(.*?)\/\//", '&lt;em&gt;$1&lt;/em&gt;', $text); $text = preg_replace('/\-\-(.*?)\-\-/', '&lt;strike&gt;$1&lt;/strike&gt;', $text); $text = preg_replace('/\[\[Image:(.*?)\|(.*?)\]\]/', '&lt;img src="$1" alt="$2" title="$2" /&gt;', $text); $text = preg_replace('/\[(.*?) (.*?)\]/', '&lt;a target="_blank" href="$1" title="$2"&gt;$2&lt;/a&gt;', $text); $text = preg_replace('/&amp;gt;(.*?)\n/', '&lt;blockquote&gt;$1&lt;/blockquote&gt;', $text); $text = preg_replace('/\* (.*?)\n/', '&lt;ul&gt;&lt;li&gt;$1&lt;/li&gt;&lt;/ul&gt;', $text); $text = preg_replace('/&lt;\/ul&gt;&lt;ul&gt;/', '', $text); $text = preg_replace('/# (.*?)\n/', '&lt;ol&gt;&lt;li&gt;$1&lt;/li&gt;&lt;/ol&gt;', $text); $text = preg_replace('/&lt;\/ol&gt;&lt;ol&gt;/', '', $text); $text = '&lt;div class="wikiText"&gt;'.$text.'&lt;/div&gt;'; return $text; } ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload