0

I am trying to create a regex expression that does not allow some string to start or end with "-". I tryied this one so far, but it does not works on Safari.

.+(?

Any ideas on how to do that?

Thanks in advance

.+(?

1 Answers1

2

Will this work?

^([^\-])(.*)([^\-])$

Or this version if you can also have 1 or 2 character values

^([^\-])(.*)([^\-])$|^(([^\-]){0,2})$
scunliffe
  • 62,582
  • 25
  • 126
  • 161