2|15|100|103|106|108|124|125|1400...
This pattern is used to match item numbers (think SKU) that do not need to be processed. The pattern was given to us by our end users as a requirement. I know what you're thinking, just put in exactly what you have above! The issue is that the 2, 15, 100, 103, 106, etc may match in other parts of item numbers. For example, 2 is in any number such as 12, 24, and 2007. None of the last three numbers listed were being processed even though they are not an exception because they match with the 2. I need a way to specifically match 2 and 2 only. I'll show you how below!
tl;dr Read below
BPA uses the .Net Regular Expression Engine so I used the following site for help.
http://regexhero.net/reference/
- I tell the regex engine that only the 2 is important.
- [2]
- I want to make sure nothing appears BEFORE the 2 so...
- (?<!pattern) checks that a pattern doesn't exist BEFORE the location.
- (?<!\w) \w is the special character for all alphanumeric characters.
- (?<!\w)[2]
- I want to make sure nothing appears AFTER the 2 as well.
- (?!pattern) checks that a pattern doesn't exist AFTER the location.
- (?<!\w)[2](?!\w) again, \w is the special character for all alphanumeric characters.
- The final regex would like like this:
- (?<!\w)[2](?!\w)|(?<!\w)[1][5](?!\w)|100|103|106|108|124|125|1400...
- Based on which components need to be specific to match to.
- In this example it is 2 and 15.
No comments:
Post a Comment