Write your own regular expression

Posted by Karthikreddy under Regular Expressions category on | Points: 40 | Views : 2594
here some instructions to write your own regular expression

1. ^ Start of a line.

2. $ End of a line.

3. . Any character except a newline.

4. a* Any sequence of zero or more a's.

5. a+ Any sequence of one or more a's.

6. a? Either zero or one a.

7. [^-a-d] Any character which is not either a dash, a, b,
c, d or newline.

8. de|abc Either the sequence `de' or `abc'.

9. (abc)* Zero or more times the sequence `abc'.

10. \. Matches a single dot; use \ to quote any of the
magic characters to get rid of their special
meaning. See also $\ variable substitution.

These were only samples, of course, any more complex com-
bination is valid as well.

The following token meanings are special procmail exten-

^ or $ Match a newline (for multiline matches).

^^ Anchor the expression at the very start of the
search area, or if encountered at the end of the
expression, anchor it at the very end of the
search area.

\< or \> Match the character before or after a word.
They are merely a shorthand for `[^a-zA-Z0-9_]',
but can also match newlines. Since they match
actual characters, they are only suitable to
delimit words, not to delimit inter-word space.

\/ Splits the expression in two parts. Everything
matching the right part will be assigned to the
MATCH environment variable.

Comments or Responses

Login to post response