Sample Header Ad - 728x90

In a regular expression, which characters need escaping?

38 votes
8 answers
79405 views
In general, which characters in a regular expression need escaping? For example, the following is not syntactically correct: echo '[]' | grep '[]' grep: Unmatched [ or [^ This, however, *is* syntatically correct: echo '[]' | grep '\[]' [] Is there any documentation on which characters should be escaped in a regular expression, and which should not?
Asked by LanceBaynes (41465 rep)
Sep 15, 2011, 06:25 PM
Last activity: Jun 20, 2025, 02:41 PM