Le 07/03/2011 11:47, Stan Hoeppner a écrit :
> mouss put forth on 3/6/2011 7:03 PM:
> 
>> /^.*foo/
>> means "it starts with something followed by foo". and this is the same
>> thing as "it contains foo", which is represented by
>> /foo/
> 
> I was taught to always start my expressions with "/^" and end them with
> "$/".  Why did Steven teach me to do this if it's not necessary?  Steven
> being the author of the Enemies List:  http://enemieslist.com/ which
> contains over 65,000 regexes matching FQrDNS patterns.
> 

You misunderstood what Steven meant. what Stevens meant is to avoid
things like
/adsl/          REJECT blah

so he recommends anchoring expressions, right and left:
/^cpe\..*\.joe\.example$/       ...

contrast this with
/^cpe/  ...
and
/adsl/  ...

which could match a lot of places you wouldn't want to match.

/^.*foo/ means: starts with anything followed by "foo". this is the same
as "contains foo", which can be represented by /foo/

and

/foo.*$/ means contains "foo" followed by anything. this is the same as
"contains foo", which can be represented by /foo/


of course, I appreciate Steven and I agree with what he says here, to
some extent (obviously, I'm paid by my employer so it's easy for me to
push for freely available stuff).


>> [snip]

Reply via email to