I am trying to include an udev rule to create a customized /dev/ entry depending on usb device attribute. I have two different bar code scanner which have the word Bar code Scanner and Barcode Scanner into manufacturer attrs.
So I am wondering if can I make it work by add regex into ATTRS{manufacturer}, as following:
ATTRS{manufacturer}=="(([bB]ar\ ?[Cc]ode\ ?)([Ss]can\ ?(ner)?))"
or should I:
ATTRS{manufacturer}=="\([Bb]ar\(\s\?\)[Cc]ode\s\?[Ss]can\)"
The regex presented above will accept the following variations:
Bar code Scanner
barcode scanner
barcodescanner
Barcode Scanner
bar code scanner
bar code scan
Bar Code Scan
BarCode Scaner
barCode scanner
From udev man page, udev supports shell-style globs rather than regular expressions:
It supports the following pattern characters:
- "*" Matches zero, one, or more characters.
- "?" Matches any single character, but does not match zero characters.
- "[ ]" Matches any single character specified within the brackets. For example, the pattern string "tty[SR]" would match either "ttyS" or "ttyR". Ranges are also supported within this match with the '-' character. For example, to match on the range of all digits, the pattern [0-9] would be used. If the first character following the '[' is a '!', any character not enclosed is matched.
- "|" Separates alternative patterns. For example, the pattern string "abc|x*" would match either "abc" or "x*".
In your case "[Bb]ar[Cc]ode [Ss]can*|[Bb]ar [Cc]ode [Ss]can*"
should work.