In order to grasp the application that is expressed in deelx as soon as possible, a smallProgram(I always believe that learning with questions will inspire our initiative to a greater extent and deepen our understanding of knowledge ).
The following instance program is mainly used to match a stringCodeIn ("|" "->" "=" "=" "+" "-"), note the "=" and "= ", the regular expression "=" should be preferentially matched.
I will not explain it much. I will go to the code.
# Include <iostream> # include "deelx. H" using namespace STD; int main () {string REX = "(=) | ((? [^ =! +-*]) =) | (->) |-| + | (\ |) "; String math =" int A = 12; if (a = B) return p-> X; "; static cregexpt <char> Regexp (Rex. c_str (); ccontext * pcontext = Regexp. preparematch (math. c_str (); matchresult result = Regexp. match (pcontext); While (result. ismatched () {int start = result. getstart (); int end = result. getend (); cout <math. substr (START, end-Start) <Endl; Result = Regexp. match (pcontext);} Regexp. releasecontext (pcontext); Return 0 ;}
Program running result:
=
=
->