Skip to content
Snippets Groups Projects
Commit 1ae6914a authored by mattijs's avatar mattijs
Browse files

split off regular expressions

parent 749a4bb5
Branches
Tags
No related merge requests found
......@@ -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;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment