![]() |
Type in a command, or "ls dictionary" to search all commands for "dictionary", etc.
|
NAME
match - Run a RegExp pattern against a string
SYNOPSIS
match [STRING] [-url [URL FOR PAGE TO USE AS STRING]] -pattern [REGEXP PATTERN] -nbrmatches [RETURN NUMBER OF MATCHES?] -matchnbr [RETURN MATCH AT] -capture [CAPTURE?] -as [AS] -callback [CALLBACK]
EXAMPLES
match <div>hello</div>blah -pattern /<div>.*?<\/div>/
returns an XML-style 'array' with one element, '<div>hello</div>'
match <div>hello</div>blah<div>hi</div> -pattern /<div>.*?<\/div>/
returns an XML-style 'array' with two elements, '<div>hello</div>' and '<div>hi</div>'
match <div>hello</div>blah -pattern /<div>.*?<\/div>/ -as xoxo
returns an XOXO-style 'array' with one element, '<div>hello</div>'
match <div>hello</div>blah -pattern /<div>.*?<\/div>/ -as json [-callback x]
returns a JSON-style 'array' with one element, '<div>hello</div>'
(using optional JSONP callback of x)
match <div>hello</div>blah -pattern /<div>.*?<\/div>/ -nbrmatches 1
returns 1 (the number of matches)
match <div>hello</div>blah -pattern /<div>.*?<\/div>/ -matchnbr 1
returns <div>hello</div> (the first match)
match <div>hello</div>blah -pattern /<div>(.*)?<\/div>/ -capture 1
returns an XML-style 'array' with one element, 'hello' (the captured item)
match -url http://yubnub.org/kernel/man?args=match -pattern /<pre>[^\f]*?<\/pre>/
returns an XML-style 'array' with one element, the text from this man page
NOTES
If you use capture parenthesis in your pattern you must pass -capture 1 to get
the captured data.
The RegExp pattern must be enclosed in the appropriate // and be RegExp-safe
(ie and / or \ escaped out at \/ or \\)
For a more boolean RegExp function see ifMatch
AUTHOR
Stephen Paul Weber
http://singpolyma-tech.blogspot.com/