regex - Removing comments from a group of php files via command line in Windows -


i have bunch of files , send them deployment sans comments whitespace intact (so can make quick changes in production in emergency cases).

the comments can either single line comments (#, //) or multi line syntax /**/ , @ indentation level.

i want create batch file when executed directory reads php files , strips comments.

i not sure try. know can fetch files .php extension , loop through them. replacing content easy enough well. stuck on how remove comments.

there's multiple ways it, think efficient use regular expressions. i'm not regexp guru, know can use grep (or powerfull text editor such notepad++, sublimetext, et...) replace expressions highlighted empty string.

for example, in sublime text, i've tested regular expression, find multiple lines comment :

\/\*([\s\s]*?)\*/|//.*|#.* 

quick explanation :

  • the regexp made of 3, or symbol inside ( pipe symbol |)
  • the first expression mean "something starting /*, character, or blank character , , finishing */"
  • the second means "any expression starting // , character following
  • the third means "any expression starting # , character following

once you've set search expression in sublime text, can replace did return "blank" replacement.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -