regex - Javascript split by square brackets and numbers -
how can use js split function split string closing square bracket character (]) numbers, '1' '2' '3' etc?
i tried this:
text.split(/[\\[123456789]/); but it's not splitting correctly.
use regex: /\]|\d+/
example below:
string = 'example] 0.. 12.. 3.. some] numbers 1232'; document.body.innerhtml = string.split(/\]|\d+/).join`<br>`; explaining:
\] # literal ']' character | # or \d+ # number if want split each digit instead of whole number remove plus + sign. + plus sign there match \d digits in group.
Comments
Post a Comment