I'm trying to write a bash script to replace the newline characters and *s from comments, but only if that comment contains a particular substring.
// file.txt
/**
* Here is a multiline
* comment that contains substring
* rest of it
*/
/**
* Here is a multiline
* comment that does not contain subNOTstring
* rest of it
*/
I would like the final result to be:
// file.txt
/** Here is a multiline comment that contains substring rest of it */
/**
* Here is a multiline
* comment that does not contain subNOTstring
* rest of it
*/
I have a regex that matches multiline comments: \/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*\/ but can't figure out the second part, of only matching with the substring, and then replacing all the /n * with just
So to make sure my question is articulated correctly
- Make a match of a substring within a file. i.e. comment
- Make sure that match includes
substring. - Replace all substring within the first match with another string. i.e.
n/ *with