Hello everyone. Could someone help me to figure out how correctly to use regex to split string by 10 letters. So I’ve got long string like this "00101010100000000010001011101000101110100000111111**********00001011110000111111000010111000101110100000111010". I need to split this string by 10 letters in order to transfer later letters to morse character. I came with this approach
let str="00101010100000000010001011101000101110100000111111****** 00001011110000111111000010111000101110100000111010"; console.log(str.match(/\d{10}/g));
It splits string by 10, however it omits this symbol *. Could you please help me to figure out, how can I split string and symbol by 10? Thanks in advance for your time!
I also tried this
let str = "00101010100000000010001011101000101110100000111111**** 00001011110000111111000010111000101110100000111010"; console.log(str.match(/^\d{10}\W{10}\d{10}$/g));
But it also doesn’t work((
Also for input there’s always numbers 10 and 11 and 10 asterisks. So I need to split long string consisting of numbers and 10 asterisks by 10, then convert it to Morse character.
Yes I know about split function. But I need long string to be divided equally by 10 letters also including symbol *. I tried to use split however didn’t get a result, which I need. Thanks. Could you please share how you may split and will get a result, which I wrote before?
Slice will cut only part of it. However I need to split long string into an array where each string’s length will be 10. Also including symbol *. If I just do regex with g flag it splits long string into an array, however it skips symbol *. I need this symbol also. I hope explained correctly what I want.