I am trying to replace a spaces within a string with hypen.
For example
'this is a sample'
should be
'this-is-a-sample'
.replace('/\s+/g', '-')
gives an error
Invalid string literal '/\s+/g'. Illegal character sequence '\s' in string literal.
/
delimiters... and backslashes may be escaped. So more like this:.replaceAll('\\s+', '-')