I would like to remove a string pattern which like this
You should not remove this /*This is the part should remove*/ You should not remove this
I would like to remove all the text inside the
In the interests of teach-a-man-to-fish vs. give-a-man-a-fish I'm linking you to a tutorial on regular expressions. regular-expressions.info/quickstart.html
In case you need a quick solution, here is what you would do: Open the file in vim, and type the following:
This is supposed to replace all of your strings beginning /* and ending */ with a space. I linked you to the regex tutorial first in case I butchered the expression I wrote. Either read the tutorial and write your own command, or make a backup before you use the line above.
Try the following quick and dirty sed line:
This will show you the output, but will not actually modify the file, once you've run it and confirmed that it makes the changes you want, then put
What it actually does it takes everything between the
I give you the non-modification method first just in case I butchered my regular expression (working off memory, and no access to sed on current machine to test right quick). Also be aware that this won't work if the text to be remove cross lines, as sed works on each line individually. If you need a program to work on multiple lines of text at once, you'll need either awk or possibly perl (neither of which I know enough to offer code suggestions for).