SCRIPT MERIDIAN
REGEX PROJECT
 

Regex Home

Download

Documentation

 Regex Verbs
  regex.compile
  regex.easyMatch
  regex.easySearch
  regex.extract
  regex.free
  regex.grep
  regex.init
  regex.join
  regex.match
  regex.quoteRE
  regex.search
  regex.split
  regex.subst
  regex.visit

 MatchInfo Table
 Metacharacters

Pointers

Credits

 

regex.grep

Syntax regex.grep (expr, adrObject, includeMatches)
Params expr is a regular expression (string) or the address of a script.

adrObject is the address of either a list object or an object that can be coerced into a string.

includeMatches is an optional boolean flag. Defaults to true.
Action Attempts to match expr on each line/element of the object pointed to by adrObject.
Returns A list from the lines/elements that passed (or failed) the test.
Examples local (s = {"a", "", "b", "", "c"});
regex.grep ("\\w", @s)
    » {"a", "b", "c"}

local (s = {"a", "", "b", "", "c"});
regex.grep ("\\w", @s, false)
    » {"", ""}
Notes If adrObject is the address of a list object, the verb operates on each element of the string, otherwise the verb operates on each line of the object, providing it can be coerced to a string.

If expr is a regular expression, it is tested against each line or element of the target object for a match.

If expr is the address of a script, the script is called for each line or element in the target object. The script receives a string as a parameter (the line or element from the object being examined) and returns either true or false.

If includeMatches is true,all matching lines or elements are included in the result list. If it is false, the result list is built from the non-matching lines/items.



 [ Previous ]  [ Next  To the top  

Send questions and comments to regex@lists.scriptmeridian.org.
Page last updated: Thu, 10 Dec 1998 21:58:09 GMT.