BE_RegularExpression

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

A perl compatible regular expression testing function.

Version : 3.2
Version : 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.

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.

Examples :

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

To get a list of all the files that end in ".fmp12" for example, you can do :

BE_ValuesUnique ( BE_RegularExpression ( BE_FileListFolder ( $path ) ; "^.*fmp12$" ; "v" ) )

The above example uses BE_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.

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

Have more questions? Submit a request

0 Comments

Article is closed for comments.