1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 \*---------------------------------------------------------------------------*/
28 #include "IOstreams.H"
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 int main(int argc, char *argv[])
43 std::string s1("this .* file");
44 Foam::string s2("this .* file");
45 const char * s3 = "this .* file";
47 wordRe(s1, wordRe::DETECT).info(Info) << endl;
48 wordRe(s2).info(Info) << endl;
49 wordRe(s2, wordRe::DETECT).info(Info) << endl;
50 wordRe(s3, wordRe::REGEXP).info(Info) << endl;
53 wre.info(Info) << endl;
55 wre.info(Info) << endl;
57 wre.info(Info) << endl;
60 wre.info(Info) << " before" << endl;
62 wre.info(Info) << " uncompiled" << endl;
63 wre.compile(wordRe::DETECT);
64 wre.info(Info) << " after DETECT" << endl;
65 wre.compile(wordRe::NOCASE);
66 wre.info(Info) << " after NOCASE" << endl;
67 wre.compile(wordRe::DETECT_NOCASE);
68 wre.info(Info) << " after DETECT_NOCASE" << endl;
70 wre = "something .* value";
71 wre.info(Info) << " before" << endl;
73 wre.info(Info) << " uncompiled" << endl;
74 wre.compile(wordRe::DETECT);
75 wre.info(Info) << " after DETECT" << endl;
77 wre.info(Info) << " uncompiled" << endl;
79 wre.info(Info) << " recompiled" << endl;
81 wre.set("something .* value", wordRe::LITERAL);
82 wre.info(Info) << " set as LITERAL" << endl;
84 IOobject::writeDivider(Info);
86 List<Tuple2<wordRe, string> > rawList(IFstream("testRegexps")());
87 Info<< "input list:" << rawList << endl;
88 IOobject::writeDivider(Info) << endl;
90 forAll(rawList, elemI)
92 const wordRe& wre = rawList[elemI].first();
93 const string& str = rawList[elemI].second();
96 << " equals:" << (wre == str)
97 << "(" << wre.match(str, true) << ")"
98 << " match:" << wre.match(str)
103 wre2.set(wre, wordRe::NOCASE);
106 << " match:" << wre2.match(str)
118 // ************************************************************************* //