Ken Herron wrote: > Ken Bloom wrote: > >> How can I match, in one regexp strings that begin with "att_" but do not >> begin with "att_appraisal"? > > > In perl or something with perl's regexp capabilities, you'd use a > negative lookahead: > > ^att_(?!appraisal)
irb(main):001:0> "att_products".match(/^att_(?!appraisal)/) => #<MatchData:0xb7cf80c4> irb(main):002:0> "att_appraisal".match(/^att_(?!appraisal)/) => nil Works like a charm in Ruby. Thanks! > Without that, your best bet is to combine two regexps using boolean logic: > > if (/^att_/ && !/^att_appraisal/) This is what I changed it to before sending the message. > You could do this with one regexp but it's ugly: > > ^att_($|[^a]|a($|[^p]|p($|[^p]|p($[^r]|... > > i.e., "att_" followed by end-of-string OR not-a OR a followed by (end of > string OR not-p OR p followed by.. I thought of that, but I *most definitely* wasn't going to try it. Thanks --Ken -- I usually have a GPG digital signature included as an attachment. See http://www.gnupg.org/ for info about these digital signatures.
signature.asc
Description: OpenPGP digital signature
_______________________________________________ vox-tech mailing list [email protected] http://lists.lugod.org/mailman/listinfo/vox-tech
