Search the Community
Showing results for tags 'character classes'.
-
Page 444 example 3: I don't understand why the regular expression of checking if a string contains no spaces doesn't work for me. This works fine and prints TRUE: $pattern = '/^\S$/'; $subject = 'a'; But this prints FALSE: $pattern = '/^\S$/'; $subject = 'aa'; It doesn't have any spaces, so why is it FALSE?
-
Hi Larry, Your pattern ^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$ provides for reasonably good email validation. However, your tip #2 warns that it will allow some invalid addresses to pass through (like ones starting with a period or containing multiple periods together). So, can I eliminate this by going with the word boundaries like this: \b[\w.-]+@[\w.-]+.[A-Za-z]{2,6}\b If you, and other forum participants, also find it 'not good at all' or 'worse than the original one', please share your ideas and reasons as I really want to strive for the better one for it. Thanks in advance. Eric