Regular Expressions: An Introduction
Published: January 12, 2004
User Rating: 8.9 (274 votes)
Ok, we have done few examples and now lets go an check out few special characters that have special meaning in the pattern. We 'll be taking them section by section.
Back Slash (\): Back Slash (\) is treated as the escape charater in the the regex patterns. Black Slash (\) and the character followed by it, together have special meaning in the pattern. Depending on what is after the slash, different, the combination has different meaning.
In the regexp, the characters dot (.), multiply (*), back slash (\) have special meaning. What is we wanted to include these special characters into the match itself ? What if we wanted to match a file name which contains both the back slash (\) and a dot (.). How would we do that ? Simple, just escape them. i.e. add a back slash (\) before them. Similary, you can escape, other special characters (which we haven't discussed)
However, if the slash is followed by any one of the following, it has a special meaning. I have taken the few absolutely necessay combinations here. For more combinations you can read through the references.
Taking a few examples