regexp


A regular expression class for string manipulation.

Library

Helper<ToolKit>

Declaration

#include <ospace/helper/regexp.h>

class os_regexp

Enums

enum os_regexp::syntax
  {
  emacs,
  awk,
  posix_awk,
  grep,
  egrep,
  posix_egrep,
  posix_basic,
  posix_extended,
  };

Interface

Constructor
os_regexp()
Default constructs a regular expression object.
Constructor
os_regexp( const string& pattern , bool use_fastmap, bool ignore_case )
Constructs a regular expression object with pattern . If use_fastmap (default false ) is true , uses an internal buffer to optimize searches. If ignore_case (default false ) is true , pattern matching is case insensitive.
Destructor
~os_regexp()
Destroys this object.
default_syntax
/* static */ syntax default_syntax()
Returns the default syntax which is used when compiling patterns.
default_syntax
/* static */ void default_syntax( syntax new_syntax )
Sets the syntax to new_syntax , which is used when compiling patterns.
group
os_regexp::range group( size_t number ) const
Returns a range to subexpression group number in the regular expression pattern. If number is 0 , the substring contains the entire pattern. If number does not represent a valid subexpression group, an empty substring is returned.
groups
size_t groups() const
Returns the number of subexpression groups in the regular expression pattern. This does not include the whole expression.
match
int match( const string& s , size_t pos , size_t len )
Searches the string s , starting at pos (default 0 ) for length len (default npos ), and returns the number of characters that match the regular expression pattern. If no match is found, returns 0 .
not_found
/* static */ range not_found()
Returns a range which represents a search failure. The search() and group() functions return this object when the search string does not contain the pattern.
pattern
void pattern( const string& pattern , bool use_fastmap, bool ignore_case )
Assigns the regular expression value to pattern . If use_fastmap (default false ) is true , uses an internal buffer to optimize searches.  If ignore_case (default false ) is true , pattern matching is case insensitive.
replace
size_t replace( const string& s , size_t pos , size_t len , const string& r , bool global )
Searches the string s , starting at pos for length len , for a substring matching the regular expression pattern and replaces it with the string r . If global (default false ) is true , replaces all occurrences of the pattern in string s . Returns the number of substitutions that occurred.
search
os_regexp::range search( const string& s , size_t pos , size_t len )
Searches for the pattern starting from the position pos (default 0 ) extending to length len (default npos ) in the string s , and returns a range for the first sequence that matches the regular expression pattern. If no match is found, returns an empty range.

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.