I want to split string
"abcdefgh"
to
"ab","cd","ef","gh"
using javascript split()
"abcdefgh".split(???)
Can you please help ?
To split a string with specific character as delimiter in Java, call split() method on the string object, and pass the specific character as argument to the split() method. The method returns a String Array with the splits as elements in the array.
Method 1: Split multiple characters from string using re. split() This is the most efficient and commonly used method to split multiple characters at once. It makes use of regex(regular expressions) in order to do this.
Python split() method is used to split the string into chunks, and it accepts one argument called separator. A separator can be any character or a symbol. If no separators are defined, then it will split the given string and whitespace will be used by default.
How to VB.NET String. Split() The VB.Net Split() extracts the substrings from the given string that are delimited by the separator parameter, and returns those substrings as elements of an array. If your String contains "dd-mm-yy", split on the "-" character to get an array of: "dd" "mm" "yy".
Instead of split
, try match
:
var text = "abcdefgh";
print(text.match(/../g));
prints:
ab,cd,ef,gh
as you can see on Ideone.
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