I have here a phrase AAC Barcode Description that regex should match.
The problem is sometimes I have underscore, symbols etc... like
- AAC Barcode Descriptions
- AAC Barcode Description
- AAC Barcode & Descriptions
- AAC Barcode and Description
REGEX
\b\w*AAC Barcode Description\w*\b
CodePudding user response:
You can use
\w*AAC Barcode(?:\s and\s |\W )Description\w*
See the regex demo. Note that word boundaries are redundant in this case when used with \w*s. If you want to match this string is a whole word, you need to remove \w*s and keep \bs:
\bAAC Barcode(?:\s and\s |\W )Description\b
Details:
\w*- zero or more word charsAAC Barcode- a fixed string(?:\s and\s |\W )- a non-capturing group matching eitherandenclosed with one or more whitespaces or one or more non-word charsDescription- a fixed string\w*- zero or more word chars
