mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-12-28 03:37:59 +00:00
ENH: SubStrings::str(int) method for similarity with std::smatch
- 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;
This commit is contained in:
@ -10,27 +10,29 @@
|
||||
|
||||
// Pattern, String
|
||||
(
|
||||
( "a.*" "abc" ) // true
|
||||
( "a.*" "bac" ) // false - partial match only
|
||||
( "a.*" "abcd" ) // true
|
||||
( "a.*" "def" ) // false
|
||||
( ".*a.*" "Abc" ) // false
|
||||
( "(?i).*a.*" "Abc" ) // true
|
||||
( "d(.*)f" "def" ) // true
|
||||
(
|
||||
( 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"
|
||||
) // true
|
||||
|
||||
)
|
||||
(
|
||||
false // partial match only
|
||||
"[[:digit:]]"
|
||||
"contains 1 or more digits"
|
||||
) // false - partial match only
|
||||
|
||||
)
|
||||
(
|
||||
true
|
||||
"[[:digit:]]+-[[:digit:]]+-[[:digit:]]+-[[:digit:]]+"
|
||||
"1-905-123-2234"
|
||||
) // true
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user