Start a new topic

$1, $3, $5 Dictionary replacement values etc

I worked out a regular expression (value) to enable me to automatically tribute gifts once a new column is inserted into a CSV Excel report (data file) and the configuration profiles associated with ImportOmatic. The Regular Expression looks like this:


\d|[1-9]\d{5}


The limiter on the number of numbers is essential for it to not become a runaway expression. Using a test facility it successfully extracts both numeric and alphanumeric ID numbers whilst ignoring blank lines and only alpha lines.


I now need to choose which dollar expression to use as a Replacement value on the left. I expect it should be $1. Could someone confirm this for me please?


Parentheses are used both to denote subsets and to mark off sub-strings of string to be returned by $1, $2, etc.  They're numbering is left to right from the first set of parenthesis in the pattern.

In other words suppose you have a regex:

(<some-special-matching>.*?(<different-matching>)


$1 would return whatever was matched by the first set of parens and $2 would match whatever was matched by the second.

(Don't ask me what happens if you try to nest parentheses because I forget.)


So, if you're wanting to return everything you matched, then I would think you would want to put parentheses around that whole expression and the replacement value is $1.

But what was this testing?  Was it from something outside of Omatic?  Regular expressions sometimes behave a little bit differently from one program to the next.

Thanks Isaac. We use the ImportOmatic plugin with Excel CSV files (reports) containing data from giving sites (JustGiving, MuchLoved) to import to Raiser's Edge database. At the moment, tributing to the deceased records is carried out manually, which is very time consuming and unnecessary. Therefore, I have taken on the task of investigating how to set up automated tributing. I got part of the way some months ago, but this was based upon surname, middle name and first name dictionaries and progress was delayed by other work. Clearly, names aren't sufficiently unique, since it's possible to get more than one deceased John Smith or Jane Brown, for example. The only thing to do is to rely upon the unique Raiser's Edge ID numbers. So I've had to learn how to write a regular expression that would work and would work where there are some rows that don't have an ID number in them. The one I have come up with appears to work using a Linux test facility, so I'm hopeful.


The pattern of ID numbers can be anything from 12,123,1234,12345, 123456, sometimes with a hyphen followed by a letter immediately on the end. I've checked and the regex. works with and without the hyphen letter.

Login or Signup to post a comment