I want my regular expression to match strings that don't start with the letter A or whitespaces.
I've tried ^-|^(^(\W|A).), but it doesn't work, any ideas why?
regular expression doesn't start with character A or whitespace
^(?![A\s])
To match the whole string, you need to add .*
^(?![A\s]).*
OR
^[^A\s].*
DEMO
Strings don't start with A or Space will match also the strings starts with hyphen -, so you don't need to specify the pattern for strings starting with hyphen.
You were close:
^[^ A]
[^ A] matches anything other than A or space
^ anchors the regex at start of the string
Regex Example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With