Thursday 15 January 2015

java - REGEX.. convert X_FOO_BAR to fooBar -


I am writing a Java DAo class that reads a table's metadata and changes the column names. Based on the following rules I have a problem with REEGEX.

  - Delete the first 2 characters - With the exception of the first letter after underscores, all the letters are all letters Change in (_) symbol - Underscores   

such ...

  X_H -> H X_THE_FIND - & gt; The Fund Y_SCORE_CARD - & gt; Scorecard Y_PARTNER - & gt; Partner   

(Note: The database column contains only uppercase letters and may contain one or more underscores characters, the first 2 characters will always be either X_ or Y_. Name must be at least 3 characters.)

It can be used in 1 line:

  // assuming str string str = WordUtils.capitalizeFully (str.substring (2), new four [] {'_'}). Replacement ("_", "");    

No comments:

Post a Comment