html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<html>
<head>
<title>Split string when character changes</title>
</head>
<body>
<!--
Split string when character changes
️Note: the given string can contain all type of characters (alphanumeric, special symbols, spaces)
Example:
Input:
AaaabbbbYY@---..aaaa 555%%%%(((f)))
Output:
A
aaa
bbbb
YY
@
---
..
aaaa
555
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
body {
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
var myStr = prompt("Write a String.");
var result = "";
if(myStr !=null) {
for(z = 0; z < myStr.length; z++) {
if(myStr[z] == myStr[z-1]) {
result += myStr[z];
}else {
result += '\n' + myStr[z];
}
}
}
alert(result);
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run