Hi! i would like to avoid texts like this one: height="49" with a regular expresion.
I tought in .replaceAll("\s*="*"","");
(replaceAll is used as a method in a java class), but eclipse don't allowed me to do that. Any other suggestion?? tx!
Hi! i would like to avoid texts like this one: height="49" with a regular expresion.
I tought in .replaceAll("\s*="*"","");
(replaceAll is used as a method in a java class), but eclipse don't allowed me to do that. Any other suggestion?? tx!
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
String.replaceAll("[A-Za-z]+=\"\d+\"","")
You need to escape the \
in Java string literal to \\
, and you need to escape the "
to \"
.
.replaceAll("\\s*=\".*?\"","")
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 \ */