Reply To: grep search expression

#67446
Anonymous
Inactive

Hi All,
I’m trying to write a grep to convert improperly styled times on a calendar to the proper style.
I want the grep to find “am.” and change it to “a.m.”
But since there is the possibility of having an “am.” being part of a show title such as “Sam I am.” I wanted to use a look behind to exclude an “am.” that is preceded by an “I” and a blank space.

The negative lookbehind grep I was writing looks like this:
(am\.)(?<!I)

I also tried a positive lookbehind for an am. preceded by a space and a digit to narrow the types of am.s that could be selected
(am\.)(?<=\d)

The first one still selects the “am.” following the “I” and the space.
The second selects nothing.
Any ideas on how to use a lookbehind to select only the “am.” following a digit and a space?

This article was last modified on March 4, 2014

Comments (0)

Loading comments...