John Todd
2003-Sep-04 17:12 UTC
[Asterisk-Users] Regular expression matching for ":" - examples needed
It is again perhaps my recent spate of bad sleeping that has prevented my brain from wrapping around this explanation, or it is perhaps my inherent hatred of regular expression syntax. However, I have been unable to put this into a working form after staring at it for a while and trying different recipes. If anyone wants to take a stab at this, I'd appreciate it. (from README.variables) expr1 : expr2 The `:' operator matches expr1 against expr2, which must be a regular expression. The regular expression is anchored to the beginning of the string with an implicit `^'. If the match succeeds and the pattern contains at least one regu- lar expression subexpression `\(...\)', the string correspond- ing to `\1' is returned; otherwise the matching operator returns the number of characters matched. If the match fails and the pattern contains a regular expression subexpression the null string is returned; otherwise 0. Examples I'd like to see: 1) ${FOO} contains 12345# ${HASH} contains # If ${FOO} contains the contents of ${HASH} anywhere, go to 2. If not, goto 102 exten=> 123,1,GotoIf($[...???...]?2|102) 1.1) If the last digit of ${FOO} is ${HASH}, then goto 2. If not, goto 102. exten => 123,1,GotoIf($[...???...]?2|102) JT
Martin Pycko
2003-Sep-05 07:32 UTC
[Asterisk-Users] Regular expression matching for ":" - examples needed
> Examples I'd like to see: > > 1) > ${FOO} contains 12345# > ${HASH} contains #something like this: exten => 123,1,Gotoif($[${FOO} : 12345#]?2|102)> > If ${FOO} contains the contents of ${HASH} anywhere, go to 2. If not, goto 102 > > exten=> 123,1,GotoIf($[...???...]?2|102) > > > 1.1) > If the last digit of ${FOO} is ${HASH}, then goto 2. If not, goto 102. > > > exten => 123,1,GotoIf($[...???...]?2|102)exten => 123,1,GotoIf($[${FOO:-1:1} = ${HASH}]?2|102) assuming ${HASH} is one digit ... Martin