0

I have a working regex which is run at the end of a simple template engine to strip out any tags that have not been used or returned nothing - it works, but too well!

It is also stripping out code examples returned from the database - meaning that I cannot write the tags directly in the editor without them being stripped before rendering.

Here is the working regex and a simple use-case:

"/{~.*?~}/ms"

This will strip all tags in the following format from a passed string {~ tag ~}, including multiline tags.

Here is the new requirement, to SKIP patterns which are found inside <pre>tag</pre> or perhaps <code>tag</core> tags:

Tags wrapped in <pre>{~ curvy ~}</pre> tags should be ignored, but {~ others ~} should be removed 
{~
including 
multilines 
~} tags.

I have a Online test set-up, which is going as slow as it always goes when I have to work with Regex :(

https://regex101.com/r/ipYlZf/1

I imagine that I need to understand and merged the logic from this regex into my own:

(?s)<pre[^<]*>.*?<\/pre>(*SKIP)(*F)|\bASCII\b
Q Studio
  • 1,811
  • 3
  • 16
  • 18

0 Answers0