I\'m currently trying to make a regex to remove every of those character [0-9] \\ - * \\\' if they are either at the beginning of the string, end of the string or if they are co
You may use
^[^a-zA-Z]+|[^a-zA-Z]+$|(['* -])['* -]+|[^a-zA-Z'* -]
Replace with the backreference to Group 1 value, $1
:
s.replace(/^[^a-zA-Z]+|[^a-zA-Z]+$|(['* -])['* -]+|[^a-zA-Z'* -]/g, '$1')
See the regex demo
Details
^[^a-zA-Z]+
- one or more chars other than ASCII letters at the start of the string|
- or[^a-zA-Z]+$
- one or more chars other than ASCII letters at the end of the string|
- or(['* -])['* -]+
- a '
, *
, space or -
captured into Group 1 and then 1+ or more of such chars|
- or[^a-zA-Z'* -]
- a char other than ASCII letter, '
, *
, space or -
.