PDFix SDK  6.5.0
PsRegex Struct Referenceabstract

PsRegex class. More...

Public Member Functions

virtual void Destroy ()=0
 Destroys PsRegex resources. More...
 
virtual bool SetPattern (const wchar_t *pattern)=0
 Sets a regular expression to search for. More...
 
virtual bool Search (const wchar_t *text, int position)=0
 Searches for a match in a string. Use positions parameter to find more patterns. More...
 
virtual int GetText (wchar_t *buffer, int len)=0
 Gets a buffer containing the matched text if it finds a match, otherwise it returns 0. More...
 
virtual int GetPosition ()=0
 
virtual int GetLength ()=0
 Gets a length of the matched text. More...
 
virtual int GetNumMatches ()=0
 Gets the number of matched text in pattern. More...
 
virtual int GetMatchText (int index, wchar_t *buffer, int len)=0
 Gets the matched text by index. More...
 

Detailed Description

PsRegex class.

A regular expression is an object that describes a pattern of characters. Regular expressions are used to perform pattern-matching functions on text. It helps to recognize a logical structure in a document. NOTE: Use Perl Regular Expression Syntax to create a new pattern.

Member Function Documentation

◆ Destroy()

virtual void PsRegex::Destroy ( )
pure virtual

Destroys PsRegex resources.

See also
Pdfix::CreateRegex

◆ GetLength()

virtual int PsRegex::GetLength ( )
pure virtual

Gets a length of the matched text.

Returns
Length of the matched text, otherwise it returns 0.

◆ GetMatchText()

virtual int PsRegex::GetMatchText ( int  index,
wchar_t *  buffer,
int  len 
)
pure virtual

Gets the matched text by index.

Parameters
indexThe match index to get.
buffer(filled by method) If the buffer is null function returns required length of string
lenLength of a buffer to be filled in.
Returns
Number of characters written into buffer of required length.

◆ GetNumMatches()

virtual int PsRegex::GetNumMatches ( )
pure virtual

Gets the number of matched text in pattern.

Returns
Length the number of matches.

◆ GetPosition()

virtual int PsRegex::GetPosition ( )
pure virtual

Gets a position of the matched text from the start position defined in PsRegex::Search method. NOTE: It's not a position from text buffer beginning.

Returns
Position of the matched text, otherwise it returns -1.

◆ GetText()

virtual int PsRegex::GetText ( wchar_t *  buffer,
int  len 
)
pure virtual

Gets a buffer containing the matched text if it finds a match, otherwise it returns 0.

Parameters
buffer(filled by method) If the buffer is null function returns required length of string
lenLength of a buffer to be filled in.
Returns
Number of characters written into buffer of required length.

◆ Search()

virtual bool PsRegex::Search ( const wchar_t *  text,
int  position 
)
pure virtual

Searches for a match in a string. Use positions parameter to find more patterns.

Parameters
textThe string to be searched.
positionA position in the text where to start search.
Returns
This method returns true if it finds a match, otherwise it returns false. Sample RegexSearch

◆ SetPattern()

virtual bool PsRegex::SetPattern ( const wchar_t *  pattern)
pure virtual

Sets a regular expression to search for.

Parameters
patternThe Regular expression.
Returns
true if pattern was set, false otherwise.
See also
CPsRegex::AddPatternType, CPsRegex::Search Sample RegexSetPattern