+ 2
How to Split String in js
6 Antworten
+ 3
let str = 'Koanti'.split(''); // splits by each letter
let str_1 = 'K,oanti'.split(','); // split by comma
let str_2 = [...'Koanti']; // iterate it for unicode in modern browser and 2015+ non-IE supported
+ 3
CamelBeatsSnake it won't be split it would be str.split() => [str]
+ 3
#ohh and in python
print('How are you'.split(' ')) or print([i for i in 'hello']) # ['How', 'are', 'you'] then ['h',...,'o']
+ 2
Basel.Al_hajeri?.MBH() Thanks. I made a little mistake.
+ 1
const splitStr = "a string".split(" ")
// splitStr is now an array: ["a", "string"]
The separator you pass into split(yourSeparator) is optional. This can be a string or a regular expression.
+ 1
# if String is text or have space
word='hello world !'
word=word.split()
print(word)
#if is one word
a='hello'
b=[]
for i in a:
b.append(i)
print(b)
c='hello'
d=[i for i in c]
print(d)
#For specific tasks you must write function