I'm rather new to Regex, and i'm working on this particular statement:
The input can't be empty, and it cannot contain any letters ([a-zA-Z]).
I have these 2 statements now:
Not empty: (?=\\s*\\S).*$)
No letters: ^[^a-zA-Z]
I know these 2 work. However, i need to combine them in a single statement (for use with Javascript). I have tried literally everything i can find and can think of. Putting the statements between ()'s, between []'s, separating them with |, combining them with ()(), adding and removing ^ and *$, and every combination thereof. However, it always seems to either be not empty or no letters, never both.
Can anyone help me combine these 2 statements into 1?
/^[^a-zA-Z]+$/- the+ensures there's at least one character./^[a-z]+$/i/re/is used for the regular expression re. Several languages, including JavaScript, use the same delimiter notation. See this answer for an example. Check Wikipedia for a brief history of how this came into existence.