- define regExp::results_type using SubStrings container for handling groups. This makes a later shift to std::smatch easier, but changes the regExp API for matching with groups. Previously had list element 0 for regex group 1, now list element 0 is the entire match and list element 1 is regex group 1. Old: List<std::string> mat; if (re.match(text, mat)) Info<< "group 1: " << mat[0] << nl; New: regExp::results_type mat; if (re.match(text, mat)) Info<< "group 1: " << mat.str(1) << nl;
40 lines
1.3 KiB
C++
40 lines
1.3 KiB
C++
/*--------------------------------*- C++ -*----------------------------------*\
|
|
| ========= | |
|
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
|
| \\ / O peration | Version: plus |
|
|
| \\ / A nd | Web: www.OpenFOAM.com |
|
|
| \\/ M anipulation | |
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
// Pattern, String
|
|
(
|
|
( true "a.*" "abc" )
|
|
( true "a.*" "abc" )
|
|
( false "a.*" "bac" ) // partial match only
|
|
( true "a.*" "abcd" )
|
|
( false "a.*" "def" )
|
|
( false ".*a.*" "Abc" )
|
|
( true "(?i).*a.*" "Abc" )
|
|
( true "d(.*)([xy]*)([f-p])" "def" )
|
|
( false "d(.*)([xy]*)([f-p])" "xxdef" )
|
|
( true
|
|
" *([A-Za-z]+) *= *([^ /]+) *(//.*)?"
|
|
" keyword = value // comment"
|
|
)
|
|
(
|
|
false // partial match only
|
|
"[[:digit:]]"
|
|
"contains 1 or more digits"
|
|
)
|
|
(
|
|
true
|
|
"[[:digit:]]+-[[:digit:]]+-[[:digit:]]+-[[:digit:]]+"
|
|
"1-905-123-2234"
|
|
)
|
|
|
|
)
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|