Linked Questions
10 questions linked to/from How to prevent java.lang.String.split() from creating a leading empty string?
-1
votes
2
answers
1k
views
Java split String that start with space [duplicate]
I know how to split a string by space as the following:
String[] array = string.split(" ");
This works great until I try to split string that starts with a space like
" I like apple"
The result ...
-2
votes
4
answers
398
views
Empty string added to string array when splitting for numbers [duplicate]
I am currently trying to brush up on Java for university using codebat. My goal is to take a string of any ASCII characters, split all of the numbers from the string, then return the sum of all of the ...
1
vote
6
answers
345
views
Prevent Empty values on string Split [duplicate]
I have used Split method on a String that contains + - and | and i dont wanna get that empty value, here's my code
public class Test {
public static void main(String args[]) {
String ab="+...
0
votes
0
answers
36
views
java regex to split a string by certain characters [duplicate]
I want to split a string by WHITE_SPACE, LPAREN or RPAREN.
I've tried this:
String st = "( a * b - (c * d )";
String[] subs = split.("(\\s+|\\(|\\))");
This kind of works, but it gives me empty ...
5
votes
4
answers
6k
views
String.split() - matching leading empty String prior to first delimiter?
I need to be able to split an input String by commas, semi-colons or white-space (or a mix of the three). I would also like to treat multiple consecutive delimiters in the input as a single delimiter. ...
2
votes
11
answers
5k
views
Time Conversion challenge on Hackerrank returning empty hour
I was attempting the Time Conversion challenge on Hackerrank, but for some reason, the hour field in the 24-hour representation always comes out empty. Here's the challenge -
Problem Statement
...
3
votes
2
answers
1k
views
Error when splitting a string in java
I am trying to split a string according to a certain set of delimiters.
My delimiters are: ,"():;.!? single spaces or multiple spaces.
This is the code i'm currently using,
String[] arrayOfWords= ...
0
votes
4
answers
3k
views
String split method returning first element as empty using regex
I'm trying to get the digits from the expression [1..1], using Java's split method. I'm using the regex expression ^\\[|\\.{2}|\\]$ inside split. But the split method returning me String array with ...
0
votes
3
answers
882
views
Java's split method has leading blank records that I can't suppress
I'm parsing an input file that has multiple keywords preceded by a +. The + is my delimiter in a split, with individual tokens being written to an array. The resulting array includes a blank record in ...
-1
votes
2
answers
870
views
Java: Convert encoded characters to regular string
I have a string like this in Java:
"\xd0\xb5\xd0\xbd\xd0\xb4\xd0\xbf\xd0\xbe\xd0\xb9\xd0\xbd\xd1\x82"
How can I convert it to a human readable equivalent?
Note:
actually it is GWT and this string is ...