We can find letters in the same way as we find numbers using ranges, so if we want to find any letter of the alphabet, we use the range a-z, but GREP is case-sensitive and so we need to also search for A-Z so as not to miss proper nouns and words that begin sentences. Like so:
[A-Za-z]
We enclose in brackets as usual so that we can reuse the search result in our replace dialog box. The plus sign means that we find an infinite number of letters up to the point where we hit something different to whatever is contained within the square brackets, e.g. a comma, space, semi-colon, etc.
([A-Za-z]+)
As in previous posts, we could have used {1,} but the plus sign requires less typing and the curly brace method is more useful when you want the first result to return more (or less) than one of the thing you are searching or you want to search up to a set number of them. Now all that is left is to use the result in the replace box:
This is a word with any number of upper or lowercase letters: \1
Part 1 | Part 2 | Part 3
Comments
Post a Comment