I need to split a string let's say "asdf aA asdfget aa uoiu AA" split using "aa" ignoring the case. to
"asdf " "asdfget " "uoiu "
Q #4) How to split a string in Java without delimiter or How to split each character in Java? Answer: You just have to pass (“”) in the regEx section of the Java Split() method. This will split the entire String into individual characters.
split (separator, limit) , if the separator is not in the string, it returns a one-element array with the original string in it.
You can use the split() method of String class from JDK to split a String based on a delimiter e.g. splitting a comma-separated String on a comma, breaking a pipe-delimited String on a pipe, or splitting a pipe-delimited String on a pipe.
There's no easy way to accomplish this using string.Split
. (Well, except for specifying all the permutations of the split string for each char lower/upper case in an array - not very elegant I think you'll agree.)
However, Regex.Split
should do the job quite nicely.
Example:
var parts = Regex.Split(input, "aa", RegexOptions.IgnoreCase);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With