Thursday 15 October 2015

Getting the content inside the Parenthesis in a whole String, using split() Input : (AMITABH) BACCHAN output : AMITABH

In order to get the content inside the Parenthesis of a whole String,  we can use the below code.


public class HelloWorld {
  public static void main(String[] args) {
    String str = "jhjh  (Environment) ab- ghty";
    System.out.println((str.split("\\(")[1]).split("\\)")[0]);
  }

}

In Talend you can use the below code :

(!(Relational.ISNULL(row2.Consequence)) && !(row2.Consequence.toString().isEmpty())) ? (row2.Consequence.split("\\(")[1]).split("\\)")[0] : null;

String  : (AMITABH) BACCHAN

Output : AMITABH


COURTS : CASES : LAWYERS : JUDGES : ::::::::: VICTIMS : ACCUSED

  *We have got so many SMART people in our COUNTRY. *we have got so many IIT completed SMART students in our COUNTRY. * we have got so many ...