Another regular expression tip

Steve Simon

2006-05-23

Categories: Blog post Tags: Data management

[StATS]: Another regular expression tip (May 23, 2006). Category: Data management

I had a large text file and I had to find the first example of a line that did NOT begin with the letter A. That's easier said than done, but you can use some special symbols in regular expressions to do this.

Just search for

The first caret (^) tells you that you need to restrict your attention to strings that begin a new line. The meaning of the caret changes when it is inside brackets. Inside brackets, the caret means find anything except the following character.

If you wanted to search for any line that does not begin with a letter, use the following

To find the first line that does not begin with a blank, use

This page was written by Steve Simon while working at Children's Mercy Hospital. Although I do not hold the copyright for this material, I am reproducing it here as a service, as it is no longer available on the Children's Mercy Hospital website. Need more information? I have a page with general help resources. You can also browse for pages similar to this one at

for pages similar to this one at with general help resources. You can also browse Children's Mercy Hospital website. Need more information? I have a page reproducing it here as a service, as it is no longer available on the Hospital. Although I do not hold the copyright for this material, I am This page was written by Steve Simon while working at Children's Mercy