java split string on two or more spaces except for words in quotes
Java
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);[Location, "Welcome to india", Bangalore, Channai, "IT city", Mysore]
Also in Java:
- Title
- how to change all the text in a textArea java at once
- Category
- Java
- Title
- java download file from url to string
- Category
- Java
- Title
- how to format a double in java to 2 decimal places
- Category
- Java
- Title
- How to print in console java
- Category
- Java
- Title
- calculating the percentile in java
- Category
- Java
- Title
- computeifabsent hashmap java
- Category
- Java
- Title
- java calendar add minutes
- Category
- Java
- Title
- java sql question mark
- Category
- Java
- Title
- how to add java_home in mac
- Category
- Java
- Title
- how to return the lower of two values in one line java
- Category
- Java
- Title
- java random boolean
- Category
- Java
- Title
- java public private key encryption
- Category
- Java
- Title
- is self divisor java
- Category
- Java
- Title
- difference between compile and execute in java
- Category
- Java
- Title
- transformez integer en string
- Category
- Java
- Title
- convert string to byte java
- Category
- Java
- Title
- print values of bst java
- Category
- Java
- Title
- formartted string java
- Category
- Java
- Title
- how to find length of array in java
- Category
- Java
- Title
- how to add a number to an array in java
- Category
- Java
- Title
- int to long java
- Category
- Java
- Title
- properties java 8 maven in pom xml
- Category
- Java
- Title
- labeled for loop in java
- Category
- Java
- Title
- jsonobject to java object
- Category
- Java
- Title
- input java
- Category
- Java
- Title
- android java shared preferences remove key
- Category
- Java
- Title
- creating file in specific location in java application
- Category
- Java
- Title
- java program to display characters from a to z using loop
- Category
- Java
- Title
- how to add strings together
- Category
- Java
- Title
- select photo from camera android
- Category
- Java
- Title
- how to get witdth of window android
- Category
- Java
- Title
- how to reverse a list in java
- Category
- Java
- Title
- remove extra blank spaces from string in java
- Category
- Java
- Title
- hashmaps java
- Category
- Java
- Title
- java open file
- Category
- Java
- Title
- count number of matches in two strings java
- Category
- Java
- Title
- how take inputs in java with message
- Category
- Java
- Title
- java list of a class has a string that is equal to
- Category
- Java
- Title
- jtable font size
- Category
- Java
- Title
- show menuitem when menu hovered javafx
- Category
- Java
- Title
- java next permutation
- Category
- Java
- Title
- compile java to jar in mac
- Category
- Java
- Title
- java how to read file extension
- Category
- Java
- Title
- java insert into arraylist
- Category
- Java
- Title
- java copy list
- Category
- Java
- Title
- The shrinker may have failed to optimize the Java bytecode. To disable the shrinker, pass the `--no-shrink` flag to this command.
- Category
- Java
- Title
- char array to string java
- Category
- Java
- Title
- validation list empty java
- Category
- Java
- Title
- import scanner
- Category
- Java
- Title
- java how to print a string[]
- Category
- Java
- Title
- read from elasticsearch in spark
- Category
- Java
- Title
- java permutation
- Category
- Java
- Title
- java lerp
- Category
- Java
- Title
- system.in example in java
- Category
- Java
- Title
- taking date as input in java
- Category
- Java
- Title
- using get in map in java
- Category
- Java
- Title
- get long from date java
- Category
- Java
- Title
- how to print something in java
- Category
- Java
- Title
- double round java integer
- Category
- Java
- Title
- filter and map multiple fields from java stream
- Category
- Java
- Title
- how to get multiple integer input in java
- Category
- Java
- Title
- how to use an abstract class in java
- Category
- Java
- Title
- generate all prime number less than n java
- Category
- Java
- Title
- float to string java
- Category
- Java
- Title
- how do you make a method that returns an array java
- Category
- Java
- Title
- list java replace
- Category
- Java
- Title
- bubble sort in java
- Category
- Java
- Title
- main class java
- Category
- Java
- Title
- spring data jpa inheritance repository
- Category
- Java
- Title
- find min in array java
- Category
- Java
- Title
- java observable
- Category
- Java
- Title
- java stream sort
- Category
- Java
- Title
- http client java
- Category
- Java
- Title
- add video in bootstrap
- Category
- Java
- Title
- how to add to a file in java
- Category
- Java
- Title
- how to add jar in maven java application in netbeans
- Category
- Java
- Title
- spigot kill entity
- Category
- Java
- Title
- teimpo en segundos java
- Category
- Java
- Title
- java mockito print called methods
- Category
- Java
- Title
- how to get the dimensions of a 2d array in java
- Category
- Java
- Title
- java classes and methods simple logic with comments
- Category
- Java
- Title
- how make a final variable in java
- Category
- Java
- Title
- round no in java
- Category
- Java
- Title
- boolean parse jtextfield
- Category
- Java
- Title
- java return new instance of generic type
- Category
- Java
- Title
- java set example
- Category
- Java
- Title
- hibernate Unknown integral data type for ids : java.lang.String
- Category
- Java
- Title
- How to find the length of an array in java
- Category
- Java
- Title
- character at index of string java
- Category
- Java
- Title
- java create jframe
- Category
- Java
- Title
- Java.awt graphics tutorial
- Category
- Java
- Title
- how to check the lines in a file java scanner
- Category
- Java
- Title
- take string from keyboard java
- Category
- Java
- Title
- change button color java swing
- Category
- Java
- Title
- java function for power
- Category
- Java
- Title
- bitwise operator in java
- Category
- Java
- Title
- async in fragment
- Category
- Java
- Title
- why python is slower than java
- Category
- Java
- Title
- math.pow java
- Category
- Java
- Title
- stackoverflow java enum with constructor
- Category
- Java