Special sequences make commonly used patterns easier to write. This makes sure the character is not treated in a special way. If you are unsure if a character has special meaning or not, you can put \ in front of it. Here, $ is not interpreted by a RegEx engine in a special way. \$a match if a string contains $ followed by a. For example, (a|b|c)xz match any string that matches either a or b or c followed by xz Expressionīacklash \ is used to escape various characters including all metacharacters. Parentheses () is used to group sub-patterns. Here, a|b match any string that contains either a or b Vertical bar | is used for alternation ( or operator). ExpressionĬonsider this code: matches at least 2 digits but not more than 4 digits Expression The question mark symbol ? matches zero or one occurrence of the pattern left to it. The plus symbol matches one or more occurrences of the pattern left to it. The star symbol * matches zero or more occurrences of the pattern left to it. The dollar symbol $ is used to check if a string ends with a certain character. No match (starts with a but not followed by b) The caret symbol ^ is used to check if a string starts with a certain character.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |