Lasso Soft Inc. > Home

[ regexp->findpattern ]

Method

[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.

  • Syntax
var(myRegExp = RegExp(-Find='(\\w)(\\w+)', -Replace='\\0', -Input='The quick brown fox', -IgnoreCase))
$myRegexp->FindPattern
$myRegexp->GroupCount
$myRegexp->ReplacePattern
$myRegexp->Input
$myRegexp->IgnoreCase
Examples
  • Intermediate

Search for a JPEG image filename in a CSS style and add a path

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);">

Recent Comments

No Comments found

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. > Home

 

 

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