From: Wesley J Landaker Date: 2002-05-03T04:16:19+09:00 Subject: Re: regexp help: contains only one tag On Thursday 02 May 2002 01:07 pm, Morris, Chris wrote: > def test_contains_only_a_tag > re = /.*<.*>.*/ > assert( ('' =~ re)) > assert(!(' assert(!('tag>' =~ re)) > assert(!('tag' =~ re)) > assert(!('' =~ re)) > assert(!(' ' =~ re)) > assert( (' < t a g > ' =~ re)) > assert(!('a' =~ re)) > end > > My re passes them all except the last one, which is the one I need > help with. Any takers? :) Well, /.*<.*>.*/ obviously matches your last test, so of course that's going to fail! =) Try something like this instead: re = /^[^<]*<[^<>]*>[^>]$/ (You'll need to add some extra things to verify, for instance, that the text inside the tag is valid, or whatever else you want...) -- Wesley J. Landaker - wjl@icecavern.net OpenPGP FP: C99E DF40 54F6 B625 FD48 B509 A3DE 8D79 541F F830 # (wjl@mindless.com is dead, don't use it)