{"id":4634,"date":"2014-03-30T14:13:52","date_gmt":"2014-03-30T14:13:52","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/variable-substitution-in-a-plist-can-i-define-a-value-once-and-reuse-it-in-a-manually-maintained-plist-collection-of-common-programming-errors\/"},"modified":"2014-03-30T14:13:52","modified_gmt":"2014-03-30T14:13:52","slug":"variable-substitution-in-a-plist-can-i-define-a-value-once-and-reuse-it-in-a-manually-maintained-plist-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/variable-substitution-in-a-plist-can-i-define-a-value-once-and-reuse-it-in-a-manually-maintained-plist-collection-of-common-programming-errors\/","title":{"rendered":"Variable substitution in a plist &#8211; can I define a value once and reuse it in a manually maintained plist?-Collection of common programming errors"},"content":{"rendered":"<p>How about instead of having one property and having to determine when to make a substitution, you have two properties. One will be <code>\"regex\"<\/code>, which you are currently using, the other will be a <code>\"namedRegex\"<\/code>. In another section of your plist, you can define all the named regular expression.<\/p>\n<pre><code>\"namedRegexes\" = {\n  \"regex1\" = \".*\";\n  \"regex2\" = \"[0-9]*\";\n  .\n}\n.\n\"objects\" = {\n    \"object1\" = {\n        \"regex\" = \"[A-Z]*\";\n        .\n    };\n    \"object2\" = {\n        \"namedRegex\" = \"regex1\";\n        .\n    }\n    .\n}\n<\/code><\/pre>\n<p>At runtime, you will need to look for a regex, if one does not exist, then look for a namedRegex. If there is a namedRegex, then lookup that name in namedRegexes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How about instead of having one property and having to determine when to make a substitution, you have two properties. One will be &#8220;regex&#8221;, which you are currently using, the other will be a &#8220;namedRegex&#8221;. In another section of your plist, you can define all the named regular expression. &#8220;namedRegexes&#8221; = { &#8220;regex1&#8221; = &#8220;.*&#8221;; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4634","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4634","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4634"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4634\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4634"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}