2018-07-12 20:50:22 +0800 Lauren C.: > thanks for the kind helps. > do you know what the expression in { } stands for? > > ^(\S+) - - \[(\S+).*\] \"GET (.*?/)\s+
Hi, Lauren This is quickly explained in http://perldoc.perl.org/perlrequick.html#Using-character-classes \s (lowercase) stands for a "whitespace". \S (uppercase) stands for the opposite of \s. So $name = "lauren"; if ($name =~ m{\s}) { print 'it matched' } This will not match, because there's no "whitespace" in the string. But this $name = "lauren"; if ($name =~ m{\S}) { print 'it matched' } will match, because in the string there is a character which is *not* "whitespace". For the ^ [] and .*? in the regex, those pages I the previous email help you. Best gil > On 2018/7/12 星期四 PM 8:37, Илья Рассадин wrote: > >"m{ pattern }" is regular expression to parse log string. > > > >It's equal to just "/ pattern /". Using different delimiter is convenient > >here because usually symbol "/" must be escaped with backslash "\", but if > >we use another delimiter - we can left "/" symbol unescaped and reges is > >more readable. > > > >You can further explore regex with this site https://regex101.com/r/4CGCcB/2 > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > >
signature.asc
Description: Digital signature