Skip to content
Advertisement

Why isn’t this sed command working for the regex?

I want to remove the multi-line comments in Java using sed command. The regex is working if we use character ranges like a-zA-Z0-9 etc. but not in case of word character like wS.

Test-File content:

JavaScript

Command used :

JavaScript

Expected results:

JavaScript

Actual results:

JavaScript

Advertisement

Answer

You can use grep with a regex (-E) and inverted matches (-v), i.e.:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement