From: it_says_BALLS_on_your_forehead Date: 2005-12-23T22:52:50+09:00 Subject: Re: Quick Regex Query Neowulf wrote: > Hi all, > > Really quick one for the regex gurus... > > Anyone know of a regex string which will extract out the stuff between > "from" and "not" without the spaces between? > > User root from toronto-hs-216-138-233-211.s-ip.magma.ca not allowed > because not listed in AllowUsers > > I've found something which *almost* does the job... > > \bfrom\W+(?:\w+\W+){1,6}not\b > > This is limited however, as I can't know for certain how many "words" > will make up the hostname. why do the number of words matter? i thought you only needed the 'stuff' between 'from' and 'not'. now when you say 'without the spaces between', do you mean the spaces immediately after the from, and before the not? what's wrong with: /from\s+(\w+)\s+not/ && print "$1" # i'm more familiar with Perl, not sure if $1 works in # ruby, but it should contain what's in capturing parens can you provide several examples of input and expected output that would illustrate your requirements?