T*****e 发帖数: 361 | 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 | m******t 发帖数: 2416 | | T*****e 发帖数: 361 | 3 I guess not if I understand it correctly.
String.replaceAll(String regex, String replacement)
The first parameter is for pattern searching, but the replacement
is simply a plain string and backreference does not work.
【在 m******t 的大作中提到】 : String.replaceAll()?
| T*****e 发帖数: 361 | 4 I guess not if I understand it correctly.
String.replaceAll(String regex, String replacement)
The first parameter is for pattern searching, but the replacement
is simply a plain string and backreference does not work.
【在 m******t 的大作中提到】 : String.replaceAll()?
|
|