{"id":1115,"date":"2018-05-29T19:39:05","date_gmt":"2018-05-29T18:39:05","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=1115"},"modified":"2022-07-25T08:35:46","modified_gmt":"2022-07-25T07:35:46","slug":"regexes-for-usage-in-text-editor","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/regexes-for-usage-in-text-editor\/","title":{"rendered":"Regexes for usage in Text editor"},"content":{"rendered":"\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ Replace javascript functions with anonymous functions\nFind:    function\\((.*?)\\) {\nReplace: ($1) =>\n\n\/\/ Get JSON key\/values (simple variant, use nested searches on values)\nFind:    \"(.*?)\"\\s*?\\:\\s*(.*+)\n\/\/ Find basic JSON key\/values (2)\nFind:    \"(.*?[^\\\\])\":\\s*([^,\\[\\]\\{\\}\\n]*)\n\n\/\/ Convert TSV \/ CSV  to JSON key value\nFind:    ^(.*?)\\t(.*?)$\nReplace: \"$1\": \"$2\",\n\n\/\/ Basic email regex\nFind: \\b[\\w._]+@[\\w._]+\\.[\\w._]+\\b\n\/\/ Basic url regex\nFind: (?:(?:https?|ftp):\\\/\\\/)?[\\w\/\\-?=%.]+\\.[\\w\/\\-?=%.#]+\n\/\/ Find firstname and surname or lastname\nFind: \\b([\\w-]+)\\s(.*?)\\s?([A-Z][\\w- ]+)\\b\n\n\n\/\/ Find all public properties in a C# class\nFind:    public [^\\s]+ ([^\\s]+)\\s+[;{]\n\n\/\/ Find all public properties in a C# class\nFind:    public [^\\s]+ ([^\\s]+)\\s+[;{].*}\n\/\/ Replace for mapping to this\nReplace: $1 = param.$1;\n\/\/ Replace for constructor mapping\nReplace: $1 = $1,\n\nlet re = '';\nlet str = '';\n\nlet getMatches = (re, str) => {\n    let match, matches = [];\n    while (match = re.exec(str)) {\n        matches.push(match[1]);\n    }\n    return matches;\n};\n\nlet convert = (match) => {\n    var p = match[0];\n    return `${p} = ${p},\\r\\n`;\n};\n\nlet convertAll = () => {\n    let matches = getMatches(re, str);\n    return matches.map(convert).join();\n};\n<\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[5,4],"tags":[],"class_list":["post-1115","post","type-post","status-publish","format-standard","hentry","category-javascript","category-programming"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/1115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=1115"}],"version-history":[{"count":18,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/1115\/revisions"}],"predecessor-version":[{"id":9562,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/1115\/revisions\/9562"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=1115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=1115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=1115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}