Lasso Soft Inc. > Home

[lp_regexp_encode]

Linklp_regexp_encode
AuthorBil Corry
CategoryTechnical
Version8.x
LicensePublic Domain
Posted06 Dec 2005
Updated06 Dec 2005
More by this author...

Description

Returns regexp hex-encoded text.  Use to avoid passing special regexp chars into the regexp engine.

Requires [lp_string_ucs]

Sample Usage

'
';
var:'search' = (:'ä','dog','++','\\','$');

var:'text' = 'This is a test $string with special regexp ä characters \\dog test. ++';

'Text   = ' $text '

'; 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; '
';

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.

[

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

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft