BE_RegularExpression

BE_RegularExpression(text;expression;{options; replaceString})



A perl compatible regular expression testing function.





Parameters:

- text : the text to be examined.

- expression : a "perl compatible" expression - see examples.

- options : i - case insensitive
m - multiline
s - dot matches all characters, including newline<
x - ignore whitespace
g - replace all
v - treat the input as a value list and iterate over each value

- replaceString : if not empty, then a replace is performed rather than a find.

Keywords:

RegularExpression Regular Expression Regex


Version History:

- 3.2 :

- 4.0.5 : added an extra option "v" to allow you to treat the input as a value list and perform the expression over all the values in the list.

Notes:

- More examples can be found here : http://perldoc.perl.org/perlre.html#Regular-Expressions

Code Examples:

BE_RegularExpression ( "abc 123 def" ; "[0-9]+" ) = 123<br>BE_RegularExpression ( $list; "(?:\\S(?![ ]))+$"; "igm" )


BE_ValuesUnique ( BE_RegularExpression ( BE_FileListFolder ( $path ) ; "^.*fmp12$" ; "v" ) )
get a list of all the files that end in ".fmp12"
The above example usesBE_ValuesUnique because the default leaves empty lines where the criteria doesn't match, so you'd have as many "values" as there were originally files, but anything not matching the criteria would be empty lines in the list.

While ( [ out = "" ; find = "" ; string = $string ] ; Length ( string ) > 0  ; 


[
find = BE_RegularExpression ( string ; $match ; "m" ) ;
out = List ( find ; out ) ;
remValues = RightValues ( string ; ValueCount ( string ) - 1 ) ;
remString = Right ( string ; Length ( string ) - Position ( string ; find ; 1 ; 1 ) ) ;
string = Case ( IsEmpty ( find ) ; remValues ; remString )

] ; out )<br>
This function only has a search for a single match, and the g option only works on replace. So there's no equivalent of this for a search only, except the v option, which isn't the same thing. You can simulate g for search with a While function that assumes some starting value of $string and $match. When doing this, you don't need the v option, as it continues on the next character.

Still need help? Contact Us Contact Us