Finding Numbers

Is there a way to search numbers? I know it sounds like a strange request. I’m a new writer and just found out (after writing a complete novel) that it’s bad grammar to write numbers and not spell them out. ie, 1=one, 2=two, etc.

I assume you mean “search for numbers”. Open the Find window and in the drop-down menu at the bottom (below “ignore Case”), choose the last option “Regular Expression (RegEx)”.

The expression to find any digit whether a singleton or part of a multiple digit number is: [size=150]\d[/size].

To find singleton digits only, try:

size=150\d(?!(\d|.\d))[/size].

Make sure there are no spaces before the first “(”.

This will also find digits in expressions where the rule does not apply, such as “1-5” and “6+10”, but these should be rare in non-technical writing.

You can go through the numbers 0 to 9 one at a time and change them to the corresponding words with replace all.
e.g.
Find: size=1503(?!(\d|.\d))[/size].

Replace all with: [size=150]three[/size]

If the regular expression changed some 3’s that you did not want changed (e.g. 3x3 changed to “threexthree”) you’ll have to identify these instances and change them back.

Steve

I improved the regular expressions above and shortened the comment. For those with some interest in regular expressions, take a look at the last regex. The number to be found is numeral “3”. The expression is:

size=1503(?!(\d|.\d)) [/size]

The first part size=1503[/size]

says find numerals “3” that are not preceded by a number or a period (decimal point). So
skip the “3” in “43” or in “.3”. The “?<!” indicates a “negative lookbehind” assertion. “\d” is any digit or a specific digit, like “3”, as here; “|” means “or” ; and “.” is a period, “escaped” by the backslash, because “.” by itself stands for any character.

The last portion [size=150]3(?!(\d|.\d))[/size]

says that “3” should not be followed by a number or by a period followed by a number. So skip the “3” in “34” or in “3.4”. The “?!” is a “negative lookahead” assertion, which says skip the previous expression (here “3”) if followed by the indicated expression.

A google search will find many resources for learning regular expressions

Steve

And just to reiterate, the first tip of just typing \d into the search tool with regular expressions turned on will walk you through every single digit in the file. Remember you can put your cursor after a batch of numbers to skip past a cluster, and then hit the Cmd-G shortcut to jump to the next one.

If you want to find them throughout the whole project, you can use regular expressions in Project Search as well. Click the magnifying glass icon to enable this mode, and again type in the \d code. Now you can go through only those documents that have digits, and hit Cmd-G to jump through instances within them.

But yes, as you can see, regular expressions are capable of quite a bit. :slight_smile: There are many basic tutorials on the Web if you wish to learn a few convenient codes like \d, though.