Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java split string on two or more spaces except for words in quotes

String str = "Location "Welcome  to india" Bangalore " +
             "Channai "IT city"  Mysore";

List<String> list = new ArrayList<String>();
Matcher m = Pattern.compile("([^"]S*|".+?")s*").matcher(str);
while (m.find())
    list.add(m.group(1)); // Add .replace(""", "") to remove surrounding quotes.


System.out.println(list);
Comment

java split string on two or more spaces except for words in quotes

[Location, "Welcome  to india", Bangalore, Channai, "IT city", Mysore]
Comment

PREVIOUS NEXT
Code Example
Java :: java generic array 
Java :: inputing number in java 
Java :: java jframe button 
Java :: display image from database in java servlet 
Java :: linked list sorting in java 
Java :: Unhandled exception: java.lang.InterruptedException 
Java :: jlist set selected value 
Java :: org.mockito.exceptions.misusing.WrongTypeOfReturnValue 
Java :: first and last digit sum java 
Java :: Unable to find bundled Java version. 
Java :: jdk path ubuntu 
Java :: How to compare lists of custom classes without defining equals() and hashCode()? 
Java :: java days between two dates 
Java :: dupplicate classes android 
Java :: simple date format 
Java :: java do while schleife 
Java :: how to convert int array to integer list in java 
Java :: java equals ignore case 
Java :: spring jpa count all rows 
Java :: How to perform counting sort in Java? 
Java :: multiplication table in java 
Java :: .now() java 
Java :: how to know java version in cmd 
Java :: android toast in adapter 
Java :: rps java 
Java :: event api spigot 
Java :: android studio remove action bar 
Java :: full screen dialog android 
Java :: set jframe fullscreen 
Java :: main methode java 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =