mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
split off regular expressions
This commit is contained in:
@ -25,9 +25,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "labelList.H"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <regex.h>
|
||||
#include "regularExpression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -41,24 +39,12 @@ labelList findStrings(const string& regexp, const StringList& sl)
|
||||
{
|
||||
labelList matches(sl.size());
|
||||
|
||||
regex_t *preg = new regex_t;
|
||||
|
||||
if (regcomp(preg, regexp.c_str(), REG_EXTENDED|REG_NOSUB) != 0)
|
||||
{
|
||||
WarningIn("findStrings(const string& regexp, const stringList& sl)")
|
||||
<< "Failed to compile regular expression " << regexp
|
||||
<< endl;
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
size_t nmatch = 0;
|
||||
regmatch_t *pmatch = NULL;
|
||||
regularExpression re(regexp);
|
||||
|
||||
label matchi = 0;
|
||||
forAll(sl, i)
|
||||
{
|
||||
if (regexec(preg, sl[i].c_str(), nmatch, pmatch, 0) == 0)
|
||||
if (re.matches(sl[i]))
|
||||
{
|
||||
matches[matchi++] = i;
|
||||
}
|
||||
@ -66,9 +52,6 @@ labelList findStrings(const string& regexp, const StringList& sl)
|
||||
|
||||
matches.setSize(matchi);
|
||||
|
||||
regfree(preg);
|
||||
delete preg;
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user