
- #DUPEGURU USE REGULAR EXPRESSIONS WHEN FILTERING CODE#
- #DUPEGURU USE REGULAR EXPRESSIONS WHEN FILTERING PLUS#
The replace expression can specify a & character which means that the & represents the sub-string that was found. This memory can then be used when we want to replace the found expression with a new expression. The parenthesis, besides affecting the evaluation order of the regular expression, also serves as tagged expression which is something like a temporary memory. The parenthesis affects the order of pattern evaluation and also serves as a tagged expression that can be used when replacing the matched sub-string with another expression.īrackets () enclosing a set of characters indicates that any of the enclosed characters may match the target character. The question mark (?) matches the character to its left 0 or 1 times.

#DUPEGURU USE REGULAR EXPRESSIONS WHEN FILTERING PLUS#
The plus (+) is similar to asterix but there should be at least one match of the character to the left of the + sign in the expression. The asterix (*) indicates that the character to the left of the asterix in the expression should match 0 or more times. The expression "a|b" will match a as well as b. The alternation character (|) allows either expression on its side to match the target string. The expression "abc$" will match the sub-string "abc" only if it is at the end of the string. The dollar sign ($) will match the end of the string. The caret (^) immediately following the left-bracket (" indicates that the target character should not be a digit. The expression "^A" will match an A only at the beginning of the string. In the table below the special characters are briefly described.īeginning of the string. For example, the single character regular expression “*” matches a single asterisk. If we want to search for a special character literally we must use a backslash before the special character. Therefore, this regular expression will match any character between 0 and 9, that is, any digit. The dash (-) between 0 and 9 indicates that it is a range from 0 to 9. The brackets indicate that the character being compared should match any one of the characters enclosed within the bracket. Suppose, we are looking for a numeric digit then the regular expression we would search for is “”.
#DUPEGURU USE REGULAR EXPRESSIONS WHEN FILTERING CODE#
Here’s a very brief turorial on using regular expressions before we move on to the code for handling regular expressions.

Regular expressions are strings that contains a mix of plain text and special characters to indicate what kind of matching to do.

Regular expressions are text patterns that are used for string matching. This is where regular expressions come in to our help. For example, if we want to search for numeric digit, then we basically end up searching for each digit independantly. Sometimes, a case insensitive search is also not enough. That is, the case is ignored but the sequence of the letters should be exactly the same. We can extend this kind of search to a case insensitive search where the sub-string “abc” will find strings like “Abc”, “ABC” etc. So if we search for a sub-string “abc” then the string being searched should contain these exact letters in the same sequence for a match to be found. Normally, when you search for a sub-string in a string, the match should be exact.
