I have a bunch of files with comments on netbeans, I am using netbeans to replace strings that match a certain regex pattern, I’m lost on it. The comments have the following pattern below.
import static java.util.Arrays.*;
/* 178 */ int h = 8;
/* 179 */ int d = 8;
/* 180 */ int j = 8;
/* 181 */ int a = 6;
/* */
I tried using [\\\*\d+\*\/] it removes the comments and the digits inside but it also removed the digit after the variable assignments, i.e it removed the 8 in int h = 8; and also removed the * in the import declaration.
Please help, tell me what I’m doing wrong, I just need to remove the comments with both the numbers and white-space in it. Thanks.
It uses the same regex pattern as PHP’s preg_replace();
Take out the brackets. They create a character class, which means that any
*,/,\,+, or digit is removed.