[lp_regexp_encode]
Description
Returns regexp hex-encoded text. Use to avoid passing special regexp chars into the regexp engine.
Requires [lp_string_ucs]
Parameters
-text
string, required
The string to encode.
Sample Usage
'<pre>';
var:'search' = (:'ä','dog','++','\\','$');
var:'text' = 'This is a test $string with special regexp ä characters \\dog test. ++';
'Text = ' $text '<br><br>';
iterate: $search, local:'s';
var:'encode' = lp_regexp_encode: #s;
'-' * 60 '\r\n';
'Search = ' #s '\r\n';
'Encode = ' $encode '\r\n';
'Found = ' (string_findregexp: $text, -find=$encode, -ignorecase) '\r\n';
/iterate;
'</pre>';
Source Code
Click the "Download" button below to retrieve a copy of this tag,
including the complete documentation and sample usage shown
on this page. Place the downloaded ".inc" file in your
LassoStartup folder, restart Lasso, and you can begin using this
tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[
define_tag:'lp_regexp_encode',
-description='Returns regexp hex-encoded text.',
-priority='replace',
-required='text';
// use to avoid passing special regexp chars into the regexp engine
// http://www.pcre.org/pcre.txt
local:'return' = string;
// encode regexp chars
iterate: #text, local:'char';
#return += '\\x{' (lp_string_ucs: #char, -hex) '}';
/iterate;
return: @#return;
/define_tag;
]
Comments
none