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:
Mark Olesen
2018-02-22 09:28:03 +01:00
parent f959927910
commit ec38e7a408
16 changed files with 264 additions and 226 deletions

View File

@ -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;