How to get a string present within single quotes in a line using java [closed]

If I understand your question right I think what you want is to use split().

String a = "This is a 'long' string to test and there are 'many' more to come to 'test'";
    String[] b = a.split("'");
    System.out.println(b[1]);

b becomes an array of strings and the second element in the array will be the string between the first set of single quotes.

Leave a Comment