RegularExpressionInterface Class Reference 系统

#include <stringregularexpression.h>

详细描述

Class to operate with regular expressions. This class is not a complete regular expression parser. It supports only a subset of regular expressions. Supported functions are:

公共成员函数

MAXON_METHOD Result < void >  InitExpression (const String ®ularExpression)
MAXON_METHOD Result < void >  InitSimpleExpression (const String &simpleExpression)
MAXON_METHOD Result < Bool Find (const String &text, REGPARSEMODE 模式, Bool onlyFirst, Int *resPos, String *resPattern)
MAXON_METHOD Result < Bool FindNext (const String &text, Int *resPos, String *resPattern)

静态公共成员函数

static MAXON_METHOD RegularExpressionInterface Alloc ( MAXON_SOURCE_LOCATION_DECLARATION )

私有成员函数

  MAXON_INTERFACE_NONVIRTUAL ( RegularExpressionInterface , MAXON_REFERENCE_NORMAL , "net.maxon.interface.regularexpression")

成员函数文档编制

◆  MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( RegularExpressionInterface   ,
MAXON_REFERENCE_NORMAL   ,
"net.maxon.interface.regularexpression"   
)
private

◆  Alloc()

static MAXON_METHOD RegularExpressionInterface * Alloc ( MAXON_SOURCE_LOCATION_DECLARATION   )
static
参数
[in] allocLocation Source location.

◆  InitExpression()

MAXON_METHOD Result <void> InitExpression ( const String regularExpression )

Initializes the regular expression parser with a complex expression.

参数
[in] regularExpression A pattern string which allows the following placeholders:
  • * ... Zero or more of previous character.
  • + ... One or more of previous character.
  • . ... Any single character.
  • # ... Any single digit.
  • | ... Or condition.
  • [] ... One of the characters in the braces. E.g. [a-zA-Z] a-z or A-Z. [abc] a, b or c.
  • () ... A group of conditions. E.g. "(A|B)+" matches "ABAABB" but not "ACCCA".
返回
OK on success.

◆  InitSimpleExpression()

MAXON_METHOD Result <void> InitSimpleExpression ( const String simpleExpression )

Initializes the regular expression parser with a simple expression. It can be used to find simple strings like: "net.maxon.unittest.*" to find all unit tests.

参数
[in] simpleExpression A pattern string which allows the following placeholders:
  • * ... Zero or more of any character.
  • # ... One or more number characters (0...9). E.g. to check an ip4 address you can use the simple pattern "#.#.#.#" which matches "192.168.2.1".
  • ? ... Any single character.
  • | ... Or condition.
返回
OK on success.

◆  Find()

MAXON_METHOD Result < Bool > Find ( const String text ,
REGPARSEMODE   mode ,
Bool   onlyFirst ,
Int resPos ,
String resPattern  
)

Finds the first occurrence of the expression in the given text.

参数
[in] text The text to search through.
[in] mode Search mode for the find operation.
另请参阅
REGPARSEMODE .
参数
[in] onlyFirst Set to true if the search should return after the first finding. This speeds up search because otherwise the call will collect all further patterns.
[out] resPos Returns the position of the matching pattern.
[out] resPattern Returns the string of the matching pattern.
返回
True if the function call found any match.

◆  FindNext()

MAXON_METHOD Result < Bool > FindNext ( const String text ,
Int resPos ,
String resPattern  
)

Finds the occurrence of the expression in the given text after calling Find.

参数
[in] text The text to search through.
[out] resPos Returns the position of the matching pattern.
[out] resPattern Returns the string of the matching pattern.
返回
True if the function call found another match.