Skip to main content

GrepString

GrepString (string, regExprStr)

The GrepString function tests string for a match to the regular expression regExprStr . Returns 1 to indicate a match, or 0 for no match.

Details

regExprStr is a regular expression such as is used by the UNIX grep(1) command. It is much more powerful than the wildcard syntax used for stringmatch. See Regular Expressions for regExprStr details.

Character matching is case-sensitive by default, similar to strsearch. Prepend the Perl 5 modifier "(?i)" to match upper and lower-case text.

Examples

Test for truth that the string contains at least one digit:

if( GrepString(str,"[0-9]+") )

Test for truth that the string contains at least one "abc", "Abc", "ABC", etc:

if( GrepString(str,"(?i)abc") )	// case-insensitive test

See Also

stringmatch, cmpstr, strsearch, SplitString, sscanf, ListMatch, ReplaceString