# Finding non-conforming barcodes in Sierra

**URL:** https://forum.innovativeusers.org/t/finding-non-conforming-barcodes-in-sierra/1085
**Category:** Sierra, Millennium & Encore
**Tags:** sierra
**Created:** [May 22, 2023, 6:39pm UTC](https://forum.innovativeusers.org/t/finding-non-conforming-barcodes-in-sierra/1085 "2023-05-22T18:39:08Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![bwalkerCSU](https://forum.innovativeusers.org/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@bwalkerCSU](https://forum.innovativeusers.org/u/bwalkerCSU)
#### Post date: [May 22, 2023, 6:39pm UTC](https://forum.innovativeusers.org/t/finding-non-conforming-barcodes-in-sierra/1085/1 "2023-05-22T18:39:08Z")

</div>

I’m trying to find non-conforming barcodes in Sierra using Create Lists. I’ve been able to use Matches (R) and RegEx to find barcodes with non-numeric characters that we need to fix, but I’m unable to find a RegEx that works to identify barcodes that are either too short or too long. For reference, our barcodes are 14 digits, numbers only. I have tried any number of RegEx variants sourced from the web trying to get character counts to work, and I can’t even get Sierra to return barcodes with 0-9 of 14 characters, which should be 99% of our barcodes. Any ideas what I’m doing wrong? Here’s the basic query to try and match 14 characters that doesn’t work

`^[0-9]{14}$`

Any thoughts? Or will I just need to use SQL for this?

EDIT: Turns out even a simple query like this needs (?e) in front of it. And in a non-optimal way, I did manage to get the queries to work.

Fewer than 14 digits: `(?e)^[0-9]{1,13}$`  
Greater than 14 digits:`(?e)^[0-9]{15,99}$`

---

<div class="post-metadata">

### Author: ![wesochuck](https://forum.innovativeusers.org/user_avatar/forum.innovativeusers.org/wesochuck/32/499_2.png) [@wesochuck](https://forum.innovativeusers.org/u/wesochuck)
#### Post date: [May 23, 2023, 1:30pm UTC](https://forum.innovativeusers.org/t/finding-non-conforming-barcodes-in-sierra/1085/2 "2023-05-23T13:30:06Z")

</div>

I’m not 100% sure how this works, but I’ve cobbled together the following that works in a regex tester. I’m not on Sierra, so I can’t guarantee it works with Sierra’s regex engine.

`/^((?!^\d{14}$).)*$/gm`

Here is how ChatGPT thinks it works:

The given regular expression, `/^((?!^\d{14}$).)*$/gm`, is a regex pattern with the following components:

1. `/`: Delimiters indicating the start and end of the regular expression.
2. `^`: Matches the start of a line.
3. `(`: Begins a capturing group.
4. `(?!`: Starts a negative lookahead assertion, which means it will match if the specified pattern does not match at the current position.
5. `^`: Matches the start of a line.
6. `\d{14}`: Matches exactly 14 digits.
7. `$`: Matches the end of a line.
8. `)`: Ends the negative lookahead assertion.
9. `.`: Matches any character except a newline.
10. `)*`: Quantifier that matches zero or more occurrences of the preceding group.
11. `$`: Matches the end of a line.
12. `/`: Delimiters indicating the end of the regular expression.
13. `g`: Global flag indicating that the regular expression should be applied to all occurrences rather than stopping after the first match.
14. `m`: Multi-line flag indicating that the `^` and `$` anchors should match the start and end of each line within a multi-line string.

In summary, this regex pattern matches any line that does not consist of exactly 14 digits. The `^` and `$` anchors ensure that the entire line is checked, and the negative lookahead `(?!^\d{14}$)` ensures that the line does not match a sequence of 14 digits from the start (`^`) to the end (`$`). The `g` and `m` flags enable the pattern to be applied globally across multiple lines.

---

<div class="post-metadata">

### Author: ![wesochuck](https://forum.innovativeusers.org/user_avatar/forum.innovativeusers.org/wesochuck/32/499_2.png) [@wesochuck](https://forum.innovativeusers.org/u/wesochuck)
#### Post date: [May 23, 2023, 1:44pm UTC](https://forum.innovativeusers.org/t/finding-non-conforming-barcodes-in-sierra/1085/3 "2023-05-23T13:44:21Z")

</div>

Speaking of ChatGPT it suggested this which I think is more readable:

`/^(\d{0,13}|\d{15,})$/gm`  
OR  
`/^(?!\d{14}$).*$/gm`

---

<div class="post-metadata">

### Author: ![lreynish](https://forum.innovativeusers.org/user_avatar/forum.innovativeusers.org/lreynish/32/506_2.png) [@lreynish](https://forum.innovativeusers.org/u/lreynish)
#### Post date: [May 23, 2023, 2:47pm UTC](https://forum.innovativeusers.org/t/finding-non-conforming-barcodes-in-sierra/1085/4 "2023-05-23T14:47:56Z")

</div>

Hi Brandon:

Former Sierra admin here, I used the following RegEx snippets for the same purpose:

Fewer than 14 digits: (?e)^.{1,13}$  
Greater than 14 digits: (?e).{15}

I got those from Richard Jackson’s Playing with Matches sessions. [His latest one on the forum is from 2021](https://forum.innovativeusers.org/t/iug-2021-virtual-presentation-still-playing-with-matches-sierra-encore-eril/348). The second post at that link gives his handout and presentation (where he talks about min / max functions and uses patron barcode length as an example).
