Test 1
Test & Test 2
Test,Test 2
Test-Test2
Test/Test2
Test. Test2
Test 1 Test 2 Test 3
Test 1 Test 2 - Test 3, Test 4, Test 5
I have the following string array, I need to replace this via javascript regex to convert all of these to lowercase and separated with -.
Expected output
test-1
test-test-2
test-test2
I have been using this till now
link = str.replace(new RegExp("[^a-zA-Z0-9-]", "gi"), "-").toLowerCase();
link = link.replace("--", "-");
\nin your character class[^a-zA-Z0-9\n-]-before the2? Is that correct? If so, how are you distinguishing it from the first line?