I'm trying in regular expression to not match if '-' is at the end of a string.
Here's a partial of my regex (this is looking at domain part of url, which can't have symbols at beginning or end, but can have '-' in middle of string:
in short is there a regex code to prevent matching for '-' if it's at the end of the string? And if you can prevent it for beginning, then that would be great too.
Yes you can use 2 negative lookaheads for this:
^(?!-)- will assert failure if
-is at the beginning
(?!.*-$)- will assert failure if
-is at the end