I have a need

John Morris johnjeff at editide.us
Wed Sep 21 10:51:06 EDT 2016


Hi David and David,
  If you are not willing to use the tools available, then you are correct that it can't be done. For those who are willing, RegEx is neither voodoo nor particularly difficult. In fact, for this particular search, the expression is quite simple.

  Let's assume that you only entered the check number in the Number field. I think that is a reasonable assumption, but other scenarios could be accounted for as long as they were used consistently. Inconsistent data entry would make the search much more difficult.

  So, if we want to implement David T.'s search (checks from 1000 to 1200), we are looking for transactions where the number field contains exactly four digits: The first digit must be a one; the second digit must be either a zero, a one or a two; and the last two digits can be any numeral from zero to nine. The search expression ^1[012][0-9]{2}$ finds the desired transactions. Note that the first and last characters (^ and $) ensure that there are no other characters in the field (such as checks with five-digit numbers).

  If you want to limit the results to only check numbers greater than or equal to 1000 and strictly less than 1200 (that is, 1000 ≤ x ≤ 1199), we need to drop the 2 from the first bracket expression: ^1[01][0-9]{2}$. It does get more complex if you want to find, for example, only numbers greater than 1012 and less than 1179. The issue is that the numerals that are allowed in the later digits are contingent on what is found in the earlier digits. However, using the alternation operator, a vertical bar, we can use (^101[2-9]$|^10[2-9][0-9]$)|^11[0-7][0-9]$. Though not strictly required by the RegEx rules, I found that the search did not work correctly without the parentheses.

Best,
John

> On Sep 21, 2016, at 1:40 AM, David T. via gnucash-user <gnucash-user at gnucash.org> wrote:
> 
> David,
> 
> Perhaps you can explain in more detail how Mike can search for a range on check numbers? On my search window, the number field search options only include Contains, Match Regex, and Does not match Regex. It’s not clear (to me, at least) how a user would search for a range of check numbers. A quick search for regex number searches doesn’t yield a simple user friendly "from 1000 to 1200" search string for regex. (I understand that this could be rendered with some form of “[0-1][0-1][0-9][0-9]|2000”, but I do not consider that [or regex in general, for that matter] particularly user friendly)
> 
> David T.



More information about the gnucash-user mailing list