Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 1
    \$\begingroup\$ You can replace your regexps with [^a-z] [^A-Z] [^0-9] and you can use getBytes() instead of toCharArray() \$\endgroup\$ Commented Jul 13, 2016 at 14:14
  • \$\begingroup\$ @cliffroot Thanks. I'm pretty bad at regexes, but not using the ^ (not) was pretty dumb.. ;) \$\endgroup\$ Commented Jul 13, 2016 at 15:10
  • 1
    \$\begingroup\$ removes repetitive replaceAll calls String c(int[]a,String z){String r[]={"[^a-z]","[^A-Z]","[^0-9]"},o="";for(byte c[],i=0;i<3;){c=z.replaceAll(r[a[i++]],"").getBytes();java.util.Arrays.sort(c);o+=new String(c);}return o;} \$\endgroup\$ Commented Jul 13, 2016 at 15:49