Regular Expression for attribute/value not working in Java
I would like to avoid texts like this one: height="49" with a regular expression.
I tried .replaceAll("\s*="*"","");
(replaceAll is used as a method in a java class), but eclipse don't allowed me to do that. Any other suggestion??
You need to escape the \ in Java string literal to \\, and you need to escape the " to \".
The character and string escape sequences allow for the representation of some nongraphic characters as well as the single quote, double quote, and backslash characters in character literals (§3.10.4) and string literals (§3.10.5).
EscapeSequence: \ b /* \u0008: backspace BS */ \ t /* \u0009: horizontal tab HT */ \ n /* \u000a: linefeed LF */ \ f /* \u000c: form feed FF */ \ r /* \u000d: carriage return CR */ \ " /* \u0022: double quote " */ \ ' /* \u0027: single quote ' */ \ \ /* \u005c: backslash \ */
You need to escape the backslash and the double quotes inside the string. Also you probably meant to write .* everywhere you wrote * (though that would likely not give you the results you want either, so you should use something more specific than .).
This needs a good deal more clarification, but your specific example can be found using