Regex (object)

The Regex object wraps the boost::regex library. It provides basic access to functionality such as search, match and replace.

http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/index.html

Regex Regex Regex

Members

Data handle  

Methods

  Regex ( in Regex other )
  Regex ( in String format )
  Regex ()
Regex clone ? ()
String[] match ? ( in String s )
String replace ? ( in String s, in String r )
String[] search ? ( in String s )
Boolean set ! ( in String e )

Methods in detail

Regex ( in Regex other )

copy constructor


Regex ( in String format )

default constructor based on a pattern provided as String.


Regex ()

default constructor


Regex Regex.clone? ()

clone method


String[] Regex.match? ( in String s )

Matches a string using the regex pattern. This is based on boost::regex_match

http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/ref/regex_match.html

/*
** Example: match
*/

require Util;
  
operator entry() {

  String s = 'one house, two houses.';
  Regex r = Regex('h[a-z]*');
  report(r.search(s));
  
}

/*
** Output:

["house","houses"]

*/


String Regex.replace? ( in String s, in String r )

Replaces elements within a string within another one based on the regex pattern. This is based on boost::regex_replace

http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/ref/regex_replace.html

/*
** Example: replace
*/

require Util;
  
operator entry() {

  String s = 'one house, two houses.';
  Regex r = Regex('(h[a-z]*)');
  report(r.replace(s, 'ocean'));
  
}

/*
** Output:

one ocean, two ocean.

*/


String[] Regex.search? ( in String s )

Returns a series of search matches within the string. This is based on boost::regex_search

http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/ref/regex_search.html

/*
** Example: search
*/

require Util;
  
operator entry() {

  String s = 'one house, two houses.';
  Regex r = Regex('[a-z]*');
  report(r.search(s));
  
}

/*
** Output:

["one","house","two","houses"]

*/


Boolean Regex.set! ( in String e )

The sets the regex pattern by a string.

注釈

You need to have a fully escaped string.