Cold Help System: Programming: ColdC Reference Manual: Functions: String: regexp()


LIST regexp(STRING str, STRING regexp[, INTEGER cs])

This function matches the regular expression argument regexp against the argument str. If cs is specified and is true, the match is case-sensitive; otherwise, it is case-insensitive. If the match succeeds, regexp() returns a list of the matches in string, or zero if it did not match. If regexp is not a valid regular expression the error ~regexp is thrown.

For more information on Regular Expressions see the section ColdC Regular Expressions. The function match_regexp() is similar, and better when all that is desired is whether the regexp matches or not. Examples:

regexp("fooBAR", "bar")
=> ["BAR"]
regexp("Greg says, 'Hello.'", "^([^ ]+) says, '(.*)'$")
=> ["Greg", "Hello."]
regexp(" 300 100 200 ", "[0-9]+")
=> ["300"]
regexp("bar", "foo")
=> 0
regexp("Foo", "foo", 1)
=> 0


crypt() | explode() | lowercase() | match_begin() | match_pattern() | match_regexp() | match_template() | pad() | regexp() | strcmp() | strfmt() | strgraft() | strlen() | strsed() | strsub() | substr() | uppercase() | match_crypted() | split() | stridx()


the Cold Dark