I need some help for extracting hard coded strings out of HTML.
This is a example markup from the template engine that I use
[[if:"x";"y"]]
<p>true part</p>
[[:else]]
<p>false part</p>
[[:endif]]
[[each:ARRAY;KEY;VALUE]]
Index :[[KEY]] is :[[VALUE]]
or if VALUE is an array
Index :[[KEY]], FOO is :[[VALUE:FOO]]
[[:endeach]]
{$_TEMPLATE['VARS']}
<p><b>I want this</b> and this, {%'AND **THIS NOT**, THIS IS ALREADY TRANSLATED
SINGLE QUOTE MARK IS ESCAPED BY A BACKSLASH \' '}
LINES</p>
Currently I use that pattern />([^\<\>\n\{\}]+\S*?)+</is
but it work not reliable.
:[[VAR]]
, {$_TEMPLATE['VAR']}
and control-blocks([[if:"x";"y"]]
etc.) should not be extracted. In case of mixed text (Foo :[[has]]
bar) should Foo
and bar
extracted separately
For the attributes, I using the pattern /(placeholder|title|alt|value)\=\"([^\"\'=\{\}\[\]]*?)\"/
which is no Problem
I hope you can help me.
EDIT: Required output from this example:
true part
false part
Index
is
or if VALUE is an array
Index
, FOO is
I want this
and this
this text {%'THIS NOT,. SINGLE QUOTE MARK IS ESCAPED BY A BACKSLASH \' '} this text also
[[if:"x";"y"]]true text
[[:else]]false text
[[:endif]]` I want this as the output `this text` ` this text also` `true text` `false text` – Devtronic May 10 '15 at 05:41