OpenMS
Loading...
Searching...
No Matches
RegularExpression Class Reference

Compiled Perl-compatible regular expression, including named capture groups. More...

#include <OpenMS/DATASTRUCTURES/RegularExpression.h>

Public Member Functions

 RegularExpression ()
 Default constructor: holds no pattern (empty() is true) and matches like the pattern "".
 
 RegularExpression (const std::string &pattern)
 Compiles pattern (Perl syntax)
 
void assign (const std::string &pattern)
 Replaces the expression by pattern; copies made earlier keep the old one.
 
std::string str () const
 The pattern this expression was compiled from; "" if it holds none.
 
bool empty () const
 True only if no pattern was set; a compiled "" is not empty.
 
bool search (const std::string &text, std::string *first_match=nullptr) const
 Search text, optionally returning the first complete match.
 

Private Attributes

std::shared_ptr< const Impl > impl_
 

Friends

struct Internal::RegularExpressionAccess
 

Detailed Description

Compiled Perl-compatible regular expression, including named capture groups.

Copies share immutable compiled state. assign() replaces only this expression. The regex engine and its headers are private to OpenMS.

Constructor & Destructor Documentation

◆ RegularExpression() [1/2]

Default constructor: holds no pattern (empty() is true) and matches like the pattern "".

◆ RegularExpression() [2/2]

RegularExpression ( const std::string &  pattern)
explicit

Compiles pattern (Perl syntax)

Exceptions
std::runtime_errorif pattern is not a valid regular expression

Member Function Documentation

◆ assign()

void assign ( const std::string &  pattern)

Replaces the expression by pattern; copies made earlier keep the old one.

Exceptions
std::runtime_errorif pattern is not a valid regular expression

◆ empty()

bool empty ( ) const

True only if no pattern was set; a compiled "" is not empty.

◆ search()

bool search ( const std::string &  text,
std::string *  first_match = nullptr 
) const

Search text, optionally returning the first complete match.

Referenced by DecoyHelper::countDecoys().

◆ str()

std::string str ( ) const

The pattern this expression was compiled from; "" if it holds none.

Friends And Related Symbol Documentation

◆ Internal::RegularExpressionAccess

friend struct Internal::RegularExpressionAccess
friend

Member Data Documentation

◆ impl_

std::shared_ptr<const Impl> impl_
private