{"id":3139,"date":"2018-01-05T09:10:32","date_gmt":"2018-01-05T09:10:32","guid":{"rendered":"https:\/\/www.threesl.com\/blog\/?p=3139"},"modified":"2023-02-03T13:36:25","modified_gmt":"2023-02-03T13:36:25","slug":"special-characters-regular-expressions-escape","status":"publish","type":"post","link":"https:\/\/www.threesl.com\/blog\/special-characters-regular-expressions-escape\/","title":{"rendered":"Special characters in regexes and how to escape them"},"content":{"rendered":"<h2>Regex \u2013 Regular Expression<\/h2>\n<p>Cradle provides support for regular expressions, regular expressions are a means to find variable text in places such as:<\/p>\n<ul>\n<li>Queries<\/li>\n<li>Find dialogs<\/li>\n<li>Category recognition strings<\/li>\n<li>Category value validations<\/li>\n<\/ul>\n<p>For instance, <em>regular expressions<\/em> (regexes) can be used in queries to find all items in which <em>any frame,<\/em> or a<em> specific frame<\/em>, or any of a <em>list of frames<\/em>, contains text matching the <em>regular expression<\/em> that you are searching for. For example, if you wanted to find all items containing sequences of capital letters followed by numbers, then the regular expression would be:<\/p>\n<p>[A-Z]+[0-9]+<\/p>\n<hr \/>\n<h4>Whilst you are here, take a look at <a href=\"https:\/\/www.threesl.com\/blog\/why-is-requirements-management-essential-for-your-business\/\" target=\"&quot;\" rel=\"noopener\">Why is Requirements Management Essential for your Business?<\/a><\/h4>\n<hr \/>\n<h2>Special Characters<\/h2>\n<p>Some characters have special meanings within regexes these characters are:<\/p>\n<table style=\"width: 100%;\">\n<tbody>\n<tr>\n<td><b>Char<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<td><b>Meaning<\/b><\/td>\n<\/tr>\n<tr>\n<td>\\<\/td>\n<td>Backslash<\/td>\n<td>Used to escape a special character<\/td>\n<\/tr>\n<tr>\n<td>^<\/td>\n<td>Caret<\/td>\n<td>Beginning of a string<\/td>\n<\/tr>\n<tr>\n<td>$<\/td>\n<td>Dollar sign<\/td>\n<td>End of a string<\/td>\n<\/tr>\n<tr>\n<td>.<\/td>\n<td>Period or dot<\/td>\n<td>Matches any single character<\/td>\n<\/tr>\n<tr>\n<td>|<\/td>\n<td>Vertical bar or pipe symbol<\/td>\n<td>Matches previous OR next character\/group<\/td>\n<\/tr>\n<tr>\n<td>?<\/td>\n<td>Question mark<\/td>\n<td>Match zero or one of the previous<\/td>\n<\/tr>\n<tr>\n<td>*<\/td>\n<td>Asterisk or star<\/td>\n<td>Match zero, one or more of the previous<\/td>\n<\/tr>\n<tr>\n<td>+<\/td>\n<td>Plus sign<\/td>\n<td>Match one or more of the previous<\/td>\n<\/tr>\n<tr>\n<td>( )<\/td>\n<td>Opening and closing parenthesis<\/td>\n<td>Group characters<\/td>\n<\/tr>\n<tr>\n<td>[ ]<\/td>\n<td>Opening and closing square bracket<\/td>\n<td>Matches a range of characters<\/td>\n<\/tr>\n<tr>\n<td>{ }<\/td>\n<td>Opening and closing curly brace<\/td>\n<td>Matches a specified number of occurrences of the previous<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Examples<\/h3>\n<p><strong>Finished\\?<\/strong> matches &#8220;<strong>Finished?<\/strong>&#8221;<br \/>\n<strong>^http<\/strong> matches strings that begin with <strong>http<\/strong><br \/>\n<strong>[^0-9]<\/strong> matches <strong>any character<\/strong> not <strong>0-9<\/strong><br \/>\n<strong>ing$<\/strong> matches &#8220;<strong>exciting<\/strong>&#8221; but not &#8220;<strong>ingenious<\/strong>&#8221;<br \/>\n<strong>gr.y<\/strong> matches &#8220;<strong>gray<\/strong>&#8220;, &#8220;<strong>grey<\/strong>&#8221;<br \/>\n<strong>Red|Yellow<\/strong> matches &#8220;<strong>Red<\/strong>&#8221; or &#8220;<strong>Yellow<\/strong>&#8221;<br \/>\n<strong>colou?r<\/strong> matches <strong>colour<\/strong> and <strong>color<\/strong><br \/>\n<strong>Ah?<\/strong> matches &#8220;<strong>Al<\/strong>&#8221; or &#8220;<strong>Ah<\/strong>&#8221;<br \/>\n<strong>Ah*<\/strong> matches &#8220;<strong>Ahhhhh<\/strong>&#8221; or &#8220;<strong>A<\/strong>&#8221;<br \/>\n<strong>Ah+<\/strong> matches &#8220;<strong>Ah<\/strong>&#8221; or &#8220;<strong>Ahhh<\/strong>&#8221; but not &#8220;<strong>A<\/strong>&#8221;<br \/>\n<strong>[cbf]ar<\/strong> matches &#8220;<strong>car<\/strong>&#8220;, &#8220;<strong>bar<\/strong>&#8220;, or &#8220;<strong>far<\/strong>&#8221;<br \/>\n<strong>[a-zA-Z]<\/strong> matches<strong> ascii letters a-z<\/strong> (uppercase and lower case)<\/p>\n<h2>Using Special Characters as Literal Characters<\/h2>\n<p>If you want to use any of these as <em>literal characters<\/em> you can <em>escape special characters<\/em> with <strong>\\<\/strong> to give them their<em> literal character<\/em> meaning.<\/p>\n<h3>Example<\/h3>\n<p>If you want to match <strong>1+2=3<\/strong>, you need to use a backslash (<strong>\\<\/strong>) to escape the <strong>+<\/strong> as this character has a special meaning (Match one or more of the previous).<br \/>\nTo match the <strong>1+2=3<\/strong> as one string you would need to use the<em> regex<\/em> <strong>1\\+2=3<\/strong><\/p>\n<p>For further information on using regexes in Cradle see our <a href=\"https:\/\/www.threesl.com\/cradle\/help\/7.3\/General\/Regular%20Expressions.htm\">online help<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<aside class=\"mashsb-container mashsb-main mashsb-stretched\"><div class=\"mashsb-box\"><div class=\"mashsb-buttons\"><a class=\"mashicon-twitter mash-small mash-center mashsb-noshadow\" href=\"https:\/\/twitter.com\/intent\/tweet?text=&amp;url=https:\/\/www.threesl.com\/blog\/special-characters-regular-expressions-escape\/&amp;via=threesl\" target=\"_top\" rel=\"nofollow\"><span class=\"icon\"><\/span><span class=\"text\">Tweet<\/span><\/a><a class=\"mashicon-facebook mash-small mash-center mashsb-noshadow\" href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.threesl.com%2Fblog%2Fspecial-characters-regular-expressions-escape%2F\" target=\"_top\" rel=\"nofollow\"><span class=\"icon\"><\/span><span class=\"text\">Share<\/span><\/a><a class=\"mashicon-subscribe mash-small mash-center mashsb-noshadow\" href=\"#\" target=\"_top\" rel=\"nofollow\"><span class=\"icon\"><\/span><span class=\"text\">Newsletter<\/span><\/a><div class=\"onoffswitch2 mash-small mashsb-noshadow\" style=\"display:none\"><\/div><\/div>\n            <\/div>\n                <div style=\"clear:both\"><\/div><\/aside>\n            <!-- Share buttons by mashshare.net - Version: 4.0.47-->","protected":false},"excerpt":{"rendered":"<p>Regex \u2013 Regular Expression Cradle provides support for regular expressions, regular expressions are a means to find variable text in places such as: Queries Find dialogs Category recognition strings Category value validations For instance, regular expressions (regexes) can be used in queries to find all items in which any frame, or a specific frame, or &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.threesl.com\/blog\/special-characters-regular-expressions-escape\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Special characters in regexes and how to escape them&#8221;<\/span><\/a><\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"no","_lmt_disable":"no","footnotes":""},"categories":[6],"tags":[510,28],"class_list":["post-3139","post","type-post","status-publish","format-standard","hentry","category-tips","tag-queries","tag-workbench"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Special characters in regular expressions and how to escape them<\/title>\n<meta name=\"description\" content=\"Information on special characters in regular expressions and how you can escape them to include them in your match\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.threesl.com\/blog\/special-characters-regular-expressions-escape\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Special characters in regular expressions and how to escape them\" \/>\n<meta property=\"og:description\" content=\"Information on special characters in regular expressions and how you can escape them to include them in your match\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.threesl.com\/blog\/special-characters-regular-expressions-escape\/\" \/>\n<meta property=\"og:site_name\" content=\"3SL Blog\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/3SLCradle\" \/>\n<meta property=\"article:published_time\" content=\"2018-01-05T09:10:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-02-03T13:36:25+00:00\" \/>\n<meta name=\"author\" content=\"Phil Shaw\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@threesl\" \/>\n<meta name=\"twitter:site\" content=\"@threesl\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Phil Shaw\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/special-characters-regular-expressions-escape\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/special-characters-regular-expressions-escape\\\/\"},\"author\":{\"name\":\"Phil Shaw\",\"@id\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/#\\\/schema\\\/person\\\/0df6ae48bc2385484c2eda3fff4b77ee\"},\"headline\":\"Special characters in regexes and how to escape them\",\"datePublished\":\"2018-01-05T09:10:32+00:00\",\"dateModified\":\"2023-02-03T13:36:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/special-characters-regular-expressions-escape\\\/\"},\"wordCount\":390,\"publisher\":{\"@id\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/#organization\"},\"keywords\":[\"queries\",\"WorkBench\"],\"articleSection\":[\"Hints &amp; Tips\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/special-characters-regular-expressions-escape\\\/\",\"url\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/special-characters-regular-expressions-escape\\\/\",\"name\":\"Special characters in regular expressions and how to escape them\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/#website\"},\"datePublished\":\"2018-01-05T09:10:32+00:00\",\"dateModified\":\"2023-02-03T13:36:25+00:00\",\"description\":\"Information on special characters in regular expressions and how you can escape them to include them in your match\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/special-characters-regular-expressions-escape\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.threesl.com\\\/blog\\\/special-characters-regular-expressions-escape\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/special-characters-regular-expressions-escape\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Special characters in regexes and how to escape them\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/\",\"name\":\"3SL Blog\",\"description\":\"From concept to creation\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/#organization\",\"name\":\"3SL\",\"url\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/02\\\/3SL_Logo_Medium.png\",\"contentUrl\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/02\\\/3SL_Logo_Medium.png\",\"width\":152,\"height\":80,\"caption\":\"3SL\"},\"image\":{\"@id\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"http:\\\/\\\/facebook.com\\\/3SLCradle\",\"https:\\\/\\\/x.com\\\/threesl\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.threesl.com\\\/blog\\\/#\\\/schema\\\/person\\\/0df6ae48bc2385484c2eda3fff4b77ee\",\"name\":\"Phil Shaw\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b19783cae59e6048640b3a0c1a1b62865d1678f2b2400a08e23e331cdb4cb9b8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b19783cae59e6048640b3a0c1a1b62865d1678f2b2400a08e23e331cdb4cb9b8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b19783cae59e6048640b3a0c1a1b62865d1678f2b2400a08e23e331cdb4cb9b8?s=96&d=mm&r=g\",\"caption\":\"Phil Shaw\"},\"sameAs\":[\"https:\\\/\\\/www.threesl.com\\\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Special characters in regular expressions and how to escape them","description":"Information on special characters in regular expressions and how you can escape them to include them in your match","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.threesl.com\/blog\/special-characters-regular-expressions-escape\/","og_locale":"en_GB","og_type":"article","og_title":"Special characters in regular expressions and how to escape them","og_description":"Information on special characters in regular expressions and how you can escape them to include them in your match","og_url":"https:\/\/www.threesl.com\/blog\/special-characters-regular-expressions-escape\/","og_site_name":"3SL Blog","article_publisher":"http:\/\/facebook.com\/3SLCradle","article_published_time":"2018-01-05T09:10:32+00:00","article_modified_time":"2023-02-03T13:36:25+00:00","author":"Phil Shaw","twitter_card":"summary_large_image","twitter_creator":"@threesl","twitter_site":"@threesl","twitter_misc":{"Written by":"Phil Shaw","Estimated reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.threesl.com\/blog\/special-characters-regular-expressions-escape\/#article","isPartOf":{"@id":"https:\/\/www.threesl.com\/blog\/special-characters-regular-expressions-escape\/"},"author":{"name":"Phil Shaw","@id":"https:\/\/www.threesl.com\/blog\/#\/schema\/person\/0df6ae48bc2385484c2eda3fff4b77ee"},"headline":"Special characters in regexes and how to escape them","datePublished":"2018-01-05T09:10:32+00:00","dateModified":"2023-02-03T13:36:25+00:00","mainEntityOfPage":{"@id":"https:\/\/www.threesl.com\/blog\/special-characters-regular-expressions-escape\/"},"wordCount":390,"publisher":{"@id":"https:\/\/www.threesl.com\/blog\/#organization"},"keywords":["queries","WorkBench"],"articleSection":["Hints &amp; Tips"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/www.threesl.com\/blog\/special-characters-regular-expressions-escape\/","url":"https:\/\/www.threesl.com\/blog\/special-characters-regular-expressions-escape\/","name":"Special characters in regular expressions and how to escape them","isPartOf":{"@id":"https:\/\/www.threesl.com\/blog\/#website"},"datePublished":"2018-01-05T09:10:32+00:00","dateModified":"2023-02-03T13:36:25+00:00","description":"Information on special characters in regular expressions and how you can escape them to include them in your match","breadcrumb":{"@id":"https:\/\/www.threesl.com\/blog\/special-characters-regular-expressions-escape\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.threesl.com\/blog\/special-characters-regular-expressions-escape\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.threesl.com\/blog\/special-characters-regular-expressions-escape\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.threesl.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Special characters in regexes and how to escape them"}]},{"@type":"WebSite","@id":"https:\/\/www.threesl.com\/blog\/#website","url":"https:\/\/www.threesl.com\/blog\/","name":"3SL Blog","description":"From concept to creation","publisher":{"@id":"https:\/\/www.threesl.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.threesl.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/www.threesl.com\/blog\/#organization","name":"3SL","url":"https:\/\/www.threesl.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.threesl.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.threesl.com\/blog\/wp-content\/uploads\/2017\/02\/3SL_Logo_Medium.png","contentUrl":"https:\/\/www.threesl.com\/blog\/wp-content\/uploads\/2017\/02\/3SL_Logo_Medium.png","width":152,"height":80,"caption":"3SL"},"image":{"@id":"https:\/\/www.threesl.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["http:\/\/facebook.com\/3SLCradle","https:\/\/x.com\/threesl"]},{"@type":"Person","@id":"https:\/\/www.threesl.com\/blog\/#\/schema\/person\/0df6ae48bc2385484c2eda3fff4b77ee","name":"Phil Shaw","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/b19783cae59e6048640b3a0c1a1b62865d1678f2b2400a08e23e331cdb4cb9b8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/b19783cae59e6048640b3a0c1a1b62865d1678f2b2400a08e23e331cdb4cb9b8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b19783cae59e6048640b3a0c1a1b62865d1678f2b2400a08e23e331cdb4cb9b8?s=96&d=mm&r=g","caption":"Phil Shaw"},"sameAs":["https:\/\/www.threesl.com\/"]}]}},"modified_by":"Jan Lamb","_links":{"self":[{"href":"https:\/\/www.threesl.com\/blog\/wp-json\/wp\/v2\/posts\/3139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.threesl.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.threesl.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.threesl.com\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.threesl.com\/blog\/wp-json\/wp\/v2\/comments?post=3139"}],"version-history":[{"count":16,"href":"https:\/\/www.threesl.com\/blog\/wp-json\/wp\/v2\/posts\/3139\/revisions"}],"predecessor-version":[{"id":8294,"href":"https:\/\/www.threesl.com\/blog\/wp-json\/wp\/v2\/posts\/3139\/revisions\/8294"}],"wp:attachment":[{"href":"https:\/\/www.threesl.com\/blog\/wp-json\/wp\/v2\/media?parent=3139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.threesl.com\/blog\/wp-json\/wp\/v2\/categories?post=3139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.threesl.com\/blog\/wp-json\/wp\/v2\/tags?post=3139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}