mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: prevent conversion of string to regExp in stringListOps (closes #739)
* For most cases, this conversion would be largely unintentional
and also less efficient. If the regex is desirable, the caller
should invoke it explicitly.
For example,
findStrings(regExp(str), listOfStrings);
Or use one of the keyType, wordRe, wordRes variants instead.
If string is to be used as a plain (non-regex) matcher,
this can be directly invoked
findMatchingStrings(str, listOfStrings);
or using the ListOps instead:
findIndices(listOfStrings, str);
* provide function interfaces for keyType.
This commit is contained in:
@ -53,7 +53,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "stringList " << strLst << nl;
|
||||
|
||||
labelList matches = findStrings(".*ee.*", strLst);
|
||||
labelList matches = findStrings(regExp(".*ee.*"), strLst);
|
||||
|
||||
Info<< "matches found for regexp .*ee.* :" << nl << matches << nl;
|
||||
forAll(matches, i)
|
||||
@ -71,7 +71,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
stringList subLst = subsetStrings(".*ee.*", strLst);
|
||||
stringList subLst = subsetStrings(regExp(".*ee.*"), strLst);
|
||||
Info<< "subset stringList: " << subLst << nl;
|
||||
|
||||
subLst = subsetStrings(reLst, strLst);
|
||||
@ -80,7 +80,7 @@ int main(int argc, char *argv[])
|
||||
inplaceSubsetStrings(reLst, strLst);
|
||||
Info<< "subsetted stringList: " << strLst << nl;
|
||||
|
||||
inplaceSubsetStrings(".*l.*", strLst);
|
||||
inplaceSubsetStrings(regExp(".*l.*"), strLst);
|
||||
Info<< "subsetted stringList: " << strLst << nl;
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
Reference in New Issue
Block a user