{"id":1511,"date":"2015-11-14T22:04:13","date_gmt":"2015-11-15T06:04:13","guid":{"rendered":"http:\/\/systemsolver.com\/StatlerBlog\/?p=1511"},"modified":"2015-11-14T22:04:13","modified_gmt":"2015-11-15T06:04:13","slug":"regular-expressions-scite","status":"publish","type":"post","link":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/2015\/11\/14\/regular-expressions-scite\/","title":{"rendered":"Regex Regular expressions &#038; with Scite"},"content":{"rendered":"<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">REgular expressions drive me nuts. Mostly because I learned text search and replace in MS Word.<\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">Find everything after the last \/ including the \/ itself<\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">for LibreWriter advanced search and replace<\/p>\n<p><code>[^\/]+$<\/code><\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">For other<\/p>\n<p><code>echo string\/string\/string | \/[^\/]*$<br \/>\n<\/code><\/p>\n<p><code>everything up to the last occurrence of \/<br \/>\n<\/code><\/p>\n<pre><code>echo string | sed 's\/\\(.*\\)\/.*\/\\1\/'<\/code><\/pre>\n<pre><code>\u00a0<\/code><\/pre>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">A great site that has active testing &#8212; incredible<\/p>\n<p><a href=\"http:\/\/regexr.com\/\">http:\/\/regexr.com\/<\/a><\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">Here is a cheat sheet:<br \/>\n<a href=\"http:\/\/www.rexegg.com\/regex-quickstart.html\">http:\/\/www.rexegg.com\/regex-quickstart.html<\/a><\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">Here is a document:<br \/>\n<a href=\"https:\/\/www.princeton.edu\/~mlovett\/reference\/Regular-Expressions.pdf\">https:\/\/www.princeton.edu\/~mlovett\/reference\/Regular-Expressions.pdf<\/a><\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">Here are a few examples that work for me:<\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">Find<\/p>\n<p style=\"padding-left: 30px;\">&#8216;.*$<br \/>\nStarting with a single quote (&#8216;) or whatever you need to match, match any character (.) zero or more times (*) until the end of the line ($).<\/p>\n<p style=\"padding-left: 30px;\">(?&lt;=&#8217;).*$<br \/>\nThis basically says give me all characters that follow the &#8216; char until the end of the line.<\/p>\n<p style=\"padding-left: 30px;\">&#8216;.*?\\n<br \/>\nThis would only capture everything from &#8216; until end of that line<\/p>\n<p style=\"color: black ! important;\" data-blkn-colour=\"rgba(51,51,51,1)\">Find and replace keeping what was found:<\/p>\n<p style=\"color: black ! important; padding-left: 30px;\" data-blkn-colour=\"rgba(51,51,51,1)\">Find: any phrase with an two numbers followed by a forward slash and followed by any two numbers:<br \/>\n\\([0-9][0-9]\/[0-9][0-9] +\\)<\/p>\n<p style=\"color: black ! important; padding-left: 30px;\" data-blkn-colour=\"rgba(51,51,51,1)\">Replace:<br \/>\n\\1\\t<\/p>\n<p style=\"color: black ! important; padding-left: 30px;\" data-blkn-colour=\"rgba(51,51,51,1)\">Find: anything like 10\/21 and put it into a variable<br \/>\nThe \\( and +|) make what&#8217;s between become a variable that can be used. If there were more than one set of those separated by a dot then there would be more variables.<\/p>\n<p style=\"color: black ! important; padding-left: 30px;\" data-blkn-colour=\"rgba(51,51,51,1)\">Replace: the \\1 represents the variable while the \\t represents a tab. The result is that a tab has been inserted after the find expression.<\/p>\n<p style=\"color: black ! important; padding-left: 30px;\" data-blkn-colour=\"rgba(51,51,51,1)\">If more than one variable was used, i.e. \\(dutch+\\) \\(bros+\\) then the variables are \\1 and \\2.<br \/>\nTo replace &#8220;dutch bros&#8221; with &#8220;dutch and bros&#8221;, search for<br \/>\n\\(dutch+\\) \\(bros+\\)<br \/>\nand replace with<br \/>\n\\1 and \\2<\/p>\n","protected":false},"excerpt":{"rendered":"<p>REgular expressions drive me nuts. Mostly because I learned text search and replace in MS Word. Find everything after the last \/ including the \/ itself for LibreWriter advanced search and replace [^\/]+$ For other echo string\/string\/string | \/[^\/]*$ everything up to the last occurrence of \/ echo string | sed &#8216;s\/\\(.*\\)\/.*\/\\1\/&#8217; \u00a0 A great [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1511","post","type-post","status-publish","format-standard","hentry","category-general"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts\/1511","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/comments?post=1511"}],"version-history":[{"count":0,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts\/1511\/revisions"}],"wp:attachment":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/media?parent=1511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/categories?post=1511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/tags?post=1511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}