
23 Jun
2010
23 Jun
'10
2:50 p.m.
Is it possible to prioritise matches by the order of the alternatives? This demonstrates what I want to do: (cl-ppcre::scan-to-strings "super(man|dog|girl|woman|boy)" "this is the story of superboy and superman.") This matches "superboy" because it matches the first "super" and then tries each of the ORs until it finds "boy". What I want it to do is match according to the priority I've specified in the OR list. For example, if it finds a "superman" anywhere in the target-string it should match that before trying "superdog" etc. I know I could do this with a bit of Lisp code, but if it's possible to keep it all in the regexp I'd prefer to do that. Thanks, David Johnson-Davies