I am a real newbie regarding Regular Expressions (RegEx)
I am looking for a RegEx1 to only match strings containing no spaces.
RegEx2 to only match strings containing spaces.
Example:
RegEx1 must match "abcxyz" but NOT "abc xyz".
RegEx2 must match "abc xyz" but NOT "abcxyz".
You want to learn about character classes:
[abc]matches a character that is either ana, abor ac.[^abc]matches any character that is neither ana, abnor ac.Together with quantifiers and start- and end-of-string anchors, you’re all set.
^[^X]*$matches a string of any length that doesn’t containX.^.*X.*$matches any string that contains at least oneX.^[^X]*X[^X]*$matches a string of any length that contains exactly oneX.