I want to accept user input that contains wildcards for ref des and net names. The basic solution isn't difficult and I get good results with:
; build regular expression pattern of filter text
; put start and end anchors on text and all asterisks match "any character zero or more times"
rexCompile(buildString(parseString(strcat("^" QSC_fcData->filter "$") "*") ".*"))
(I know I can use the PCRE functions, but I started with the basic ones since they worked.)
Trouble came when I tried to find pathological cases and realized that regex special chars are common in net names (especially "+" like in "+5V"). Some regex special chars are ".\*+^$".
Starting with the first problem I encountered, I was able to modify the following code to handle a plus sign:
pat = pcreCompile("[\\+]")
rexCompile(buildString(parseString(strcat("^" pcreReplace(pat QSC_fnData->filter "\\\\+" 0) "$") "*") ".*"))
This does work and I can then accept an asterisk as a wildcard on the input and match "+5V", "+3.3V", etc. in my net names. But this is just one of the special chars. As the special chars could be in any position of the input string (ref des or net name), I don't see any one regex pattern to handle it all and doing them individually looks miserable. There must be a better way which I don't see. Searching on the forums and reading sklangref again haven't lit a bulb over my head, but it may be because I'm just daft. Can anyone help?