Java Regular Expression Question# Java - 爪哇娇娃
T*e
1 楼
In Perl, separating words with mixed caps in an identifier
like "RuntimeException" as "Runtime Exception" is fairly
easy. The regular expression for this can be:
$varName =~ s/([A-Z])/ \1/g;
or even better:
$varName =~ s/([^A-Z])([A-Z])/\1 \2/g;
$varName =~ s/([A-Z])([A-Z][a-z])/\1 \2/g;
Java's regular expression is pretty close to that of Perl
in term of searching for a pattern. However, can we do
similar replacement in Java without having to write a loop
to do searching and manua
like "RuntimeException" as "Runtime Exception" is fairly
easy. The regular expression for this can be:
$varName =~ s/([A-Z])/ \1/g;
or even better:
$varName =~ s/([^A-Z])([A-Z])/\1 \2/g;
$varName =~ s/([A-Z])([A-Z][a-z])/\1 \2/g;
Java's regular expression is pretty close to that of Perl
in term of searching for a pattern. However, can we do
similar replacement in Java without having to write a loop
to do searching and manua