I want to remind you that RegEx contains plain text and expressions (can contain only plain text). RegEx are highly case sensitive.
1.1 Matching literal text:
Text: Hello, my name is Amith. Welcome
RegEx: Amith
Result: Hello, my name is Amith
. Welcome
1.2 For Matching Any Character - .
T : cat cnt sat
RegEx: c.t
R:
cat
cnt
sat1.3 Matching special characters
A . has a special meaning in regex. If you need a . in your pattern, you need a way to tell regex that you want the actual . character and not the regex special meaning of the . character. To do this, you escape the . by preceding it with a \(backslash) . \is a metacharacter (a fancy way of saying a character with a special meaning, in contrast to the character itself). Therefore, . means match any character, and \. means match the . character itself.
T : cat cnt.a sat.txt
RegEx: sat\.txt
R: cat cnt.a
sat.txt
No comments:
Post a Comment