1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 \*---------------------------------------------------------------------------*/
29 #include "IOstreams.H"
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 int main(int argc, char *argv[])
44 std::string s1("this .* file");
45 Foam::string s2("this .* file");
46 const char * s3 = "this .* file";
48 wordRe(s1, wordRe::DETECT).info(Info) << endl;
49 wordRe(s2).info(Info) << endl;
50 wordRe(s2, wordRe::DETECT).info(Info) << endl;
51 wordRe(s3, wordRe::REGEXP).info(Info) << endl;
54 wre.info(Info) << endl;
56 wre.info(Info) << endl;
58 wre.info(Info) << endl;
61 wre.info(Info) << " before" << endl;
63 wre.info(Info) << " uncompiled" << endl;
64 wre.compile(wordRe::DETECT);
65 wre.info(Info) << " after DETECT" << endl;
66 wre.compile(wordRe::NOCASE);
67 wre.info(Info) << " after NOCASE" << endl;
68 wre.compile(wordRe::DETECT_NOCASE);
69 wre.info(Info) << " after DETECT_NOCASE" << endl;
71 wre = "something .* value";
72 wre.info(Info) << " before" << endl;
74 wre.info(Info) << " uncompiled" << endl;
75 wre.compile(wordRe::DETECT);
76 wre.info(Info) << " after DETECT" << endl;
78 wre.info(Info) << " uncompiled" << endl;
80 wre.info(Info) << " recompiled" << endl;
82 wre.set("something .* value", wordRe::LITERAL);
83 wre.info(Info) << " set as LITERAL" << endl;
85 IOobject::writeDivider(Info);
87 List<Tuple2<wordRe, string> > rawList(IFstream("testRegexps")());
88 Info<< "input list:" << rawList << endl;
89 IOobject::writeDivider(Info) << endl;
91 forAll(rawList, elemI)
93 const wordRe& wre = rawList[elemI].first();
94 const string& str = rawList[elemI].second();
97 << " equals:" << (wre == str)
98 << "(" << wre.match(str, true) << ")"
99 << " match:" << wre.match(str)
104 wre2.set(wre, wordRe::NOCASE);
107 << " match:" << wre2.match(str)
119 // ************************************************************************* //