2
06/11/2024 8:41 上午
主题启动器
I need to create a function in javascript which will replace
kebab case (dashes: "-")
with
snake cased version (underscore dash "_")
in a string.
1 答案
2
06/11/2024 8:42 上午
Here you go (with replace and regex):
function kebabToSnake(str) {
//replace all dashes with
var myString = str.replace(/-/g, "_");
//return str
return myString;
//try with: "this - is -a - ---test";
}
