Here's some explanation for some regex on the email validation patterns you found during the class:
- [A-z0-9_%+-] : matching for all alphanumeric or the symbols (eg: _%+- ) in the set.
- [\w-] : Matches any word character for \w also it's equivalent to [A-Za-z0-9_], or matching of symbol 'dash'(eg: -)
- \. : matches for dot(.); Besides dot(.), characters/symbols that need escapes include: $ ^ { [ ( | ) ] } * + ? \ which mean that if i want to find matches of + in a certain string, i'll need the pattern / \+ /, for matches of dollar sign, i may need this pattern / \$ / with the backslash in front of the symbol. For the other symbols that are not listed above eg:% ! @ < > / # ~ - _ ; : " ' ` backslash is not necessary in the pattern.
- [a-zA-Z0-9_-] == [-A-Za-z0-9_] == [0-9_A-Za-z-] : if we split the patterns in the set, we can found a-z, A-Z, 0-9, underscore(_), dash(-); when we have them writing in a set, there would be no order for which should be written first.
- [^<>()[\]\\.,;:\s@\"] :
- the most complicated case above all
- the ^(caret) that occur on the 1st place after the square bracket([]) has different meaning with the ^(caret) that place on the 1st place of a pattern.
- eg: [^aeiou] : Matches any single character not in the specified set of characters.
- which means if the string doesn't not have these symbols ( < >( )[ ] . , ; @ \ " ) , it fulfills the match.
- \s : matches any white-space character. or it's equivalent to [ \f\n\r\t\v] (eg: space, feed, new line, carriage return, tab, vertical tab)
No comments:
Post a Comment