[RegExp->FindPattern] returns the stored find pattern. If called with a parameter then that value is compiled and stored as the new find pattern.
The find pattern can be set with this method, when the regular expression object is created with [RegExp], or when calling the [RegExp->ReplaceAll], [RegExp->ReplaceFirst], or [RegExp->Split] methods.
var(myRegExp = RegExp(-Find='(\\w)(\\w+)', -Replace='\\0', -Input='The quick brown fox', -IgnoreCase))
$myRegexp->FindPattern
$myRegexp->GroupCount
$myRegexp->ReplacePattern
$myRegexp->Input
$myRegexp->IgnoreCase
Notice in the example, the grep patterns that require escaping with backslashes. For instance, the parentheses are escaped with two backslashes.
Code
// Original HTML code
// <td style="background-image:url(example.jpg);"> </td>
local('revisePath' = '\\1' + 'http://www.test.com/img/' + '\\2\\3')
local('code' = '<td colspan="4" style="background-image:url(example.jpg);">')
local('codeRegExp' = regExp(-find= '(background-image\\s*:\\s*url\\()(.+?)(\\);)', -replace= #revisePath, -input= #code, -ignoreCase))
#codeRegExp->replaceAll
Result
<td colspan="4" style="background-image:url(http://www.test.com/img/example.jpg);">
Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Recent Comments