Simple Regular Expression question

General discussions about Advanced Find and Replace
Post Reply
timshrimp
Posts: 2
Joined: Sat Dec 30, 2017 6:46 pm

Simple Regular Expression question

Post by timshrimp » Sat Dec 30, 2017 6:51 pm

Hi all!

I want to do something I think should be simple with regular expressions but I can't quite get the syntax right. I thought maybe someone else could help.

My goal is simply a find, not a find and replace.

I want to be able to find anytime there is a numeral followed by a comma and a space and then another numeral. As a separate search I want to find anytime there is a numeral followed by a space the word "and" another space and another numeral.

In short, I want to find any example of this, where "#" in these examples is any number, 0-9:

#, #
# and #

Can anyone help me out? Thanks so much!

Abacre
Site Admin
Posts: 1209
Joined: Mon Jan 31, 2005 5:32 pm

Re: Simple Regular Expression question

Post by Abacre » Sat Dec 30, 2017 7:41 pm

Is numeral only one digit or one or more digits?

In regular expressions \d represents one digit.

So you need go to to Batch replace tab.
Check Use Regular Expressions
Check Find Only.

then you may put into search for:
\d, \d
and on the second line of search for:
\d and \d

if numeral means one or more digits then you need to use \d+
Thus you need to have two lines:
\d+, \d+
\d+ and \d+
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

timshrimp
Posts: 2
Joined: Sat Dec 30, 2017 6:46 pm

Re: Simple Regular Expression question

Post by timshrimp » Sun Dec 31, 2017 4:41 am

Thanks! I'm not sure what I'm doing wrong, but that's turning up all sorts of false positives.

Should the regular expression in the batch replace should look like this for digits separated by "and" and a space on either side, or am I doing something wrong:

[\d and \d]

Thanks!

EDIT: Oops, I had the Batch Replace set to File Names only which was messing everything up. I think I'm back on track now. I'll let you know how it goes! Thanks!

Post Reply