diff --git a/applications/test/dictionary/Test-dictionary.C b/applications/test/dictionary/Test-dictionary.C
index 8659e6a28ece003ed405bb62253b7c27f0b91e2c..ea9e806543332eb666fd56291b17fdeb4bdd51bc 100644
--- a/applications/test/dictionary/Test-dictionary.C
+++ b/applications/test/dictionary/Test-dictionary.C
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
 
         {
             dictionary dict(IFstream("testDictRegex")());
-            dict.add(keyType("fooba[rz]", true), "anything");
+            dict.add(keyType("fooba[rz]", keyType::REGEX), "anything");
 
             dict.writeEntry("testDictRegex", Info);
             Info<< nl
diff --git a/applications/test/fvSolutionCombine/Test-fvSolutionCombine.C b/applications/test/fvSolutionCombine/Test-fvSolutionCombine.C
index 98902dbe006223da27f76362ff46f36135c329f5..1b9ab5dd48f0012944fbb5c0fa7df1f57e77d39e 100644
--- a/applications/test/fvSolutionCombine/Test-fvSolutionCombine.C
+++ b/applications/test/fvSolutionCombine/Test-fvSolutionCombine.C
@@ -184,7 +184,7 @@ int main(int argc, char *argv[])
                 if (names[nameI] != oldNames[nameI])
                 {
                     // make "(abc|def)" pattern
-                    keyType renamed( "(" + names[nameI] + ")", true);
+                    keyType renamed("(" + names[nameI] + ")", keyType::REGEX);
 
                     solverDict.changeKeyword(oldNames[nameI], renamed);
 
diff --git a/applications/test/wordRe/Test-wordRe.C b/applications/test/wordRe/Test-wordRe.C
index e3a7e4d47cd2df7bcb967c50c93ef56541edb646..11d8cdf43c62d559e3e6e0dbd6ae3e3997a76728 100644
--- a/applications/test/wordRe/Test-wordRe.C
+++ b/applications/test/wordRe/Test-wordRe.C
@@ -60,7 +60,7 @@ int main(int argc, char *argv[])
     Foam::string s2("this .* file");
     const char * s3 = "this .* file";
 
-    keyType keyre("x.*", true);
+    keyType keyre("x.*", keyType::REGEX);
 
     wordReList wordrelist
     {
diff --git a/src/OpenFOAM/db/dictionary/entry/entryIO.C b/src/OpenFOAM/db/dictionary/entry/entryIO.C
index 567be03c850420649e8d001db80f0ac3885d454d..186ba415aff7732303f1a59cc373fc94adf19030 100644
--- a/src/OpenFOAM/db/dictionary/entry/entryIO.C
+++ b/src/OpenFOAM/db/dictionary/entry/entryIO.C
@@ -404,7 +404,11 @@ bool Foam::entry::New
                 if (keyName.find_first_of("\"'") == 0)
                 {
                     // Begins with a quote - treat as pattern
-                    key = keyType(string::validate<keyType>(keyName), true);
+                    key = keyType
+                    (
+                        string::validate<keyType>(keyName),
+                        keyType::REGEX
+                    );
                 }
                 else
                 {
diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C
index a2e084f54235a82894d35eb8eb781b0e37d7dda8..2512e784e554df33d73cf83824e4b7de42b59cc1 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2010-2011 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2010-2011, 2019 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
                             | Copyright (C) 2011-2016 OpenFOAM Foundation
@@ -183,7 +183,7 @@ Foam::labelList Foam::processorCyclicPolyPatch::patchIDs
         keyType
         (
             "procBoundary.*to.*through" + cyclicPolyPatchName,
-            true  // isPattern
+            keyType::REGEX
         )
     );
 }
diff --git a/src/OpenFOAM/primitives/strings/keyType/keyType.C b/src/OpenFOAM/primitives/strings/keyType/keyType.C
index 05c1134357b840a91220ba3625128731585cc910..88ad70b59fac4843a97965b894cca60778fa7c55 100644
--- a/src/OpenFOAM/primitives/strings/keyType/keyType.C
+++ b/src/OpenFOAM/primitives/strings/keyType/keyType.C
@@ -39,7 +39,7 @@ const Foam::keyType Foam::keyType::null;
 Foam::keyType::keyType(Istream& is)
 :
     word(),
-    isPattern_(false)
+    type_(option::LITERAL)
 {
     is  >> *this;
 }
@@ -49,12 +49,12 @@ Foam::keyType::keyType(Istream& is)
 
 bool Foam::keyType::match(const std::string& text, bool literal) const
 {
-    if (literal || !isPattern_)
+    if (!literal && isPattern())
     {
-        return !compare(text);          // Compare as literal string
+        return regExp(*this).match(text);  // Match as regex
     }
 
-    return regExp(*this).match(text);   // Match as regex
+    return !compare(text);  // Compare as literal
 }
 
 
@@ -76,13 +76,13 @@ Foam::Istream& Foam::operator>>(Istream& is, keyType& val)
     if (t.isWord())
     {
         val = t.wordToken();
-        val.uncompile();  // Non-regex
+        val.setType(keyType::LITERAL);
     }
     else if (t.isString())
     {
         // Assign from string, treat as regular expression
         val = t.stringToken();
-        val.compile();   // As regex
+        val.setType(keyType::REGEX);
 
         // Flag empty strings as an error
         if (val.empty())
diff --git a/src/OpenFOAM/primitives/strings/keyType/keyType.H b/src/OpenFOAM/primitives/strings/keyType/keyType.H
index 20a5272464f3c0f683e1fc5860492ac8453c6484..f3ad7507e429b9b3cb15fa4806a9364b5d8b695c 100644
--- a/src/OpenFOAM/primitives/strings/keyType/keyType.H
+++ b/src/OpenFOAM/primitives/strings/keyType/keyType.H
@@ -42,6 +42,7 @@ SourceFiles
 #define keyType_H
 
 #include "word.H"
+#include "stdFoam.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -60,10 +61,32 @@ class keyType
 :
     public word
 {
+public:
+
+    // Public Data Types
+
+        //- Enumeration for the data type and search/match modes (bitmask)
+        //  eg, (keyType::REGEX | keyType::RECURSIVE)
+        enum option : unsigned char
+        {
+            // Base stored types
+            LITERAL = 0,        //!< String literal
+            REGEX   = 1,        //!< Regular expression
+
+            // Variants for search/match only
+            RECURSIVE = 0x80,   //!< Recursive search (eg, in dictionary)
+            LITERAL_RECURSIVE = (LITERAL | RECURSIVE),
+            REGEX_RECURSIVE   = (REGEX | RECURSIVE)
+        };
+
+
+private:
+
     // Private Data
 
-        //- Treat keyType as a pattern (regular expression)
-        bool isPattern_;
+        //- Treat keyType as literal, regex etc.
+        //  Never contains RECURSIVE values.
+        option type_;
 
 
     // Private Member Functions
@@ -80,20 +103,6 @@ public:
         static const keyType null;
 
 
-    // Public Data Types
-
-        //- Enumeration for search/match modes as bitmask
-        //  eg, (keyType::REGEX | keyType::RECURSIVE)
-        enum option
-        {
-            LITERAL = 0,        //!< String literal
-            REGEX   = 1,        //!< Regular expression
-            RECURSIVE = 0x10,   //!< Recursive search (eg, in dictionary)
-            LITERAL_RECURSIVE = (LITERAL | RECURSIVE),
-            REGEX_RECURSIVE   = (REGEX | RECURSIVE)
-        };
-
-
     // Constructors
 
         //- Construct null
@@ -112,7 +121,7 @@ public:
         inline keyType(const char* s);
 
         //- Copy construct from std::string with specified treatment
-        inline keyType(const std::string& s, bool isPattern);
+        inline keyType(const std::string& s, option opt);
 
         //- Move construct, retaining type (literal or regex)
         inline keyType(keyType&& s);
@@ -124,7 +133,7 @@ public:
         inline keyType(string&& s);
 
         //- Move construct from std::string with specified treatment
-        inline keyType(std::string&& s, bool isPattern);
+        inline keyType(std::string&& s, option opt);
 
         //- Construct from Istream
         //  Treat as regular expression if surrounded by quotation marks.
@@ -150,12 +159,15 @@ public:
 
     // Infrastructure
 
+        //- Change the representation
+        inline void setType(option opt, bool adjust = false);
+
         //- Mark as regular expression
         inline bool compile();
 
         //- Mark as literal, instead of a regular expression.
         //  Optionally strip invalid word characters.
-        inline void uncompile(bool doStrip = false);
+        inline void uncompile(bool adjust = false);
 
 
     // Editing
@@ -197,6 +209,17 @@ public:
 
         //- Assign as word, treat as literal
         inline void operator=(const char* s);
+
+
+    // Housekeeping
+
+        //- Deprecated(2019-08) construct as literal/regex
+        //  \deprecated(2019-08) - use Construct with option
+        FOAM_DEPRECATED_FOR(2019-08, "Construct with option")
+        keyType(const std::string& s, bool isPattern)
+        :
+            keyType(s, (isPattern ? option::REGEX : option::LITERAL))
+        {}
 };
 
 
diff --git a/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H b/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H
index b518efddcb2aba6256d2dd04383cef6ab8571b5c..7e8945c297d44b84223770e22272ad80c4d979fe 100644
--- a/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H
+++ b/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H
@@ -47,72 +47,72 @@ inline bool Foam::keyType::valid(char c)
 inline Foam::keyType::keyType()
 :
     word(),
-    isPattern_(false)
+    type_(option::LITERAL)
 {}
 
 
 inline Foam::keyType::keyType(const keyType& s)
 :
     word(s, false),
-    isPattern_(s.isPattern())
+    type_(s.type_)
 {}
 
 
 inline Foam::keyType::keyType(const word& s)
 :
     word(s, false),
-    isPattern_(false)
+    type_(option::LITERAL)
 {}
 
 
 inline Foam::keyType::keyType(const string& s)
 :
     word(s, false),
-    isPattern_(true)
+    type_(option::REGEX)
 {}
 
 
 inline Foam::keyType::keyType(const char* s)
 :
     word(s, false),
-    isPattern_(false)
+    type_(option::LITERAL)
 {}
 
 
-inline Foam::keyType::keyType(const std::string& s, bool isPattern)
+inline Foam::keyType::keyType(const std::string& s, option opt)
 :
     word(s, false),
-    isPattern_(isPattern)
+    type_(option(opt & 0x0F))
 {}
 
 
 inline Foam::keyType::keyType(keyType&& s)
 :
     word(std::move(static_cast<word&>(s)), false),
-    isPattern_(s.isPattern())
+    type_(s.type_)
 {
-    s.isPattern_ = false;
+    s.type_ = option::LITERAL;
 }
 
 
 inline Foam::keyType::keyType(word&& s)
 :
     word(std::move(s), false),
-    isPattern_(false)
+    type_(option::LITERAL)
 {}
 
 
 inline Foam::keyType::keyType(string&& s)
 :
     word(std::move(s), false),
-    isPattern_(true)
+    type_(option::REGEX)
 {}
 
 
-inline Foam::keyType::keyType(std::string&& s, bool isPattern)
+inline Foam::keyType::keyType(std::string&& s, option opt)
 :
     word(std::move(s), false),
-    isPattern_(isPattern)
+    type_(option(opt & 0x0F))
 {}
 
 
@@ -120,39 +120,50 @@ inline Foam::keyType::keyType(std::string&& s, bool isPattern)
 
 inline bool Foam::keyType::isLiteral() const
 {
-    return !isPattern_;
+    return (type_ != option::REGEX);
 }
 
 
 inline bool Foam::keyType::isPattern() const
 {
-    return isPattern_;
+    return (type_ & option::REGEX);
+}
+
+
+inline void Foam::keyType::setType(option opt, bool adjust)
+{
+    opt = option(opt & 0x0F);
+
+    if (type_ != opt)
+    {
+        // Only strip when debug is active (potentially costly operation)
+        if (isPattern() && adjust && word::debug)
+        {
+            string::stripInvalid<word>(*this);
+        }
+
+        type_ = opt;
+    }
 }
 
 
 inline bool Foam::keyType::compile()
 {
-    isPattern_ = true;
+    type_ = option::REGEX;
     return true;
 }
 
 
-inline void Foam::keyType::uncompile(bool doStrip)
+inline void Foam::keyType::uncompile(bool adjust)
 {
-    // Only strip when debug is active (potentially costly operation)
-    if (isPattern_ && doStrip && word::debug)
-    {
-        string::stripInvalid<word>(*this);
-    }
-
-    isPattern_ = false;
+    setType(option::LITERAL, adjust);
 }
 
 
 inline void Foam::keyType::clear()
 {
     word::clear();
-    isPattern_ = false;
+    type_ = option::LITERAL;
 }
 
 
@@ -165,7 +176,7 @@ inline void Foam::keyType::swap(keyType& s)
     }
 
     word::swap(static_cast<word&>(s));
-    std::swap(isPattern_, s.isPattern_);
+    std::swap(type_, s.type_);
 }
 
 
@@ -186,7 +197,7 @@ inline void Foam::keyType::operator=(const keyType& s)
     }
 
     assign(s); // Bypasses char checking
-    isPattern_ = s.isPattern_;
+    type_ = s.type_;
 }
 
 
@@ -206,21 +217,21 @@ inline void Foam::keyType::operator=(keyType&& s)
 inline void Foam::keyType::operator=(const word& s)
 {
     assign(s); // Bypasses char checking
-    isPattern_ = false;
+    type_ = option::LITERAL;
 }
 
 
 inline void Foam::keyType::operator=(const string& s)
 {
     assign(s); // Bypasses char checking
-    isPattern_ = true;
+    type_ = option::REGEX;
 }
 
 
 inline void Foam::keyType::operator=(const char* s)
 {
     assign(s); // Bypasses char checking
-    isPattern_ = false;
+    type_ = option::LITERAL;
 }
 
 
diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H
index 46366236380f30ddf402aeaa87ac51882d09091f..520ab5105991c1eda3afae86ea7437607b3f67d7 100644
--- a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H
+++ b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H
@@ -183,7 +183,7 @@ public:
 
         //- Make wordRe a literal again, instead of a regular expression.
         //  Optionally strip invalid word characters.
-        inline void uncompile(bool doStrip = false);
+        inline void uncompile(bool adjust = false);
 
 
     // Editing
diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordReI.H b/src/OpenFOAM/primitives/strings/wordRe/wordReI.H
index 046918efd60a32901c96a8f1f19c5a875b3629a8..91fbb62085273a1cb63a078e1a20a29b848fc15b 100644
--- a/src/OpenFOAM/primitives/strings/wordRe/wordReI.H
+++ b/src/OpenFOAM/primitives/strings/wordRe/wordReI.H
@@ -208,10 +208,10 @@ inline bool Foam::wordRe::compile()
 }
 
 
-inline void Foam::wordRe::uncompile(bool doStrip)
+inline void Foam::wordRe::uncompile(bool adjust)
 {
     // Only strip when debug is active (potentially costly operation)
-    if (re_.clear() && doStrip && word::debug)
+    if (re_.clear() && adjust && word::debug)
     {
         string::stripInvalid<word>(*this);
     }
@@ -227,12 +227,12 @@ inline void Foam::wordRe::clear()
 
 inline bool Foam::wordRe::match(const std::string& text, bool literal) const
 {
-    if (literal || !re_.exists())
+    if (!literal && re_.exists())
     {
-        return !compare(text);  // Compare as literal string
+        return re_.match(text);  // Match as regex
     }
 
-    return re_.match(text);     // Match as regex
+    return !compare(text);  // Compare as literal
 }