{"id":256,"date":"2015-04-21T09:51:27","date_gmt":"2015-04-21T08:51:27","guid":{"rendered":"https:\/\/mokrzycki.eu\/blog\/?p=256"},"modified":"2018-12-04T16:08:21","modified_gmt":"2018-12-04T15:08:21","slug":"android-source-code-from-grepcode-com-notepad-with-regex","status":"publish","type":"post","link":"https:\/\/mokrzycki.eu\/blog\/2015\/04\/21\/android-source-code-from-grepcode-com-notepad-with-regex\/","title":{"rendered":"Android source code from grepcode.com + Notepad++ with regex"},"content":{"rendered":"<p>Did You have problem with copying text from grepcode? Did You have problem with a lot spaces and wrong formatting?<br \/>\nWell it is possible to reformat that text with two commands using regex in notepad.<\/p>\n<p>Let&#8217;s say we have this:<br \/>\n[java]175<\/p>\n<p>176<\/p>\n<p>public void [More &#8230;] setButtonDrawable(int resid) {<\/p>\n<p>177<\/p>\n<p>if (resid != 0 &amp;&amp; resid == mButtonResource) {<\/p>\n<p>178<\/p>\n<p>return;<\/p>\n<p>179<\/p>\n<p>}[\/java]<\/p>\n<p>It is possible to convert original source to better format like this:<br \/>\n[java]<br \/>\npublic void setButtonDrawable(int resid) {<br \/>\nif (resid != 0 &amp;&amp; resid == mButtonResource) {<br \/>\nreturn;<br \/>\n}<br \/>\nmButtonResource = resid;<br \/>\nDrawable d = null;<br \/>\nif (mButtonResource != 0) {<br \/>\nd = getResources().getDrawable(mButtonResource);<br \/>\n}<br \/>\nsetButtonDrawable(d);<br \/>\n}[\/java]<\/p>\n<p><strong>How?<\/strong><\/p>\n<p>You have to paste Your selected code to Notepad++, then click CTRL+H (for replacing function). Select at the bottom option for regex. And finally make two replacing steps:<br \/>\n1. replace from [java]\\d+\\s+\\r\\n[\/java] to [java](empty text here)[\/java]<br \/>\n1. replace from [java]^[\\s+][\\r\\n$][\/java] to [java](empty text here)[\/java]<\/p>\n<p>And that&#8217;s it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Did You have problem with copying text from grepcode? Did You have problem with a&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[500],"tags":[5,30,180,179,178],"_links":{"self":[{"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/posts\/256"}],"collection":[{"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/comments?post=256"}],"version-history":[{"count":7,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/posts\/256\/revisions"}],"predecessor-version":[{"id":727,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/posts\/256\/revisions\/727"}],"wp:attachment":[{"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/media?parent=256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/categories?post=256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/tags?post=256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}