[vox-tech] Regexp question

Ken Herron kherron+lugod at fmailbox.com
Sun Jan 29 15:16:49 PST 2006


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)

Without that, your best bet is to combine two regexps using boolean logic:

	if (/^att_/ && !/^att_appraisal/)

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..


More information about the vox-tech mailing list