{"id":3393,"date":"2020-02-11T11:25:40","date_gmt":"2020-02-11T10:25:40","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=3393"},"modified":"2022-07-25T08:33:23","modified_gmt":"2022-07-25T07:33:23","slug":"find-all-classnames-attributes-in-files","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/find-all-classnames-attributes-in-files\/","title":{"rendered":"Node: Find all classnames \/ attributes in C# files"},"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=\"\">const findInFiles = require('find-in-files');\nconst folder = \"C:\\\\workspace\\\\\"\n\n\/\/const term = \"public class\\\\s+([^\\\\s]*)\";\nconst term = \"\\\\s(\\\\[[^:]+?\\\\])\\\\s\";\nconst flags = 'ig';\n\nlet classes = [];\n\nfindInFiles.find({'term': term, 'flags': flags}, folder, '.cs$')\n    .then(function(results) {\n\t\tfor (const [_, res] of Object.entries(results)) {\n\t\t\tfor (const match of res.matches) {\n\t\t\t\tconst regEx = new RegExp(term, flags);\n\t\t\t\tconst m = regEx.exec(match);\n\t\t\t\tif (m) {\n\t\t\t\t\tclasses.push(m[1])\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(\"Fail: \", match);\n\t\t\t\t}\n\t\t\t}\n        }\n\t\tconst set = new Set(classes);\n\t\tconst array = Array.from(set)\n\t\tarray.sort();\n\t\tfor(const item of array)\n\t\t{\n\t\t\tconsole.log(item);\n\t\t}\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":[6,4,1],"tags":[],"class_list":["post-3393","post","type-post","status-publish","format-standard","hentry","category-dotnet","category-programming","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/3393","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=3393"}],"version-history":[{"count":3,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/3393\/revisions"}],"predecessor-version":[{"id":3397,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/3393\/revisions\/3397"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=3393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=3393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=3393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}