I think reading the official tutorial from begin is not that comfortable
to a newbie. I bought a book "Learning Perl, 6th Edition" for studying
step by step. thanks.
On 2018/7/18 星期三 AM 9:08, Uri Guttman wrote:
also i always recommend reading the entire perl FAQ as there are many
regex tips a
On 07/17/2018 08:57 PM, Lauren C. wrote:
I did read them, but got no deep impression unless I met the issue. :)
not sure what kind of deep impression you need! :)
a key thing with docs is rereading them. read them once quickly all the
way through to get a sense of the whole picture. read aga
I did read them, but got no deep impression unless I met the issue. :)
Uri Guttman 写道:
On 07/17/2018 08:46 PM, Lauren C. wrote:
Thanks Gil. I think i know the difference of "\w+" and "\w*" now.
lauren, did you read the perlretut document? if not, you should. it
covers quantifiers early on a
On 07/17/2018 08:46 PM, Lauren C. wrote:
Thanks Gil. I think i know the difference of "\w+" and "\w*" now.
lauren, did you read the perlretut document? if not, you should. it
covers quantifiers early on as they are one of the fundamental features
of regexes. a key thing to learn is the {m,n}
yeah you explain that well. thanks.
Andy Bach 写道:
> But it doesn't work for this case:
$ perl -le '$x="/path/"; print 1 if $x=~m{path/\w+}'
> it expects 1 returned.
Well, assuming you mean it shouldn't match as $x starts with a slash and
the RE doesn't - you're on the right path. The reas
Thanks Gil. I think i know the difference of "\w+" and "\w*" now.
Gil Magno 写道:
2018-07-17 19:56:59 +0800 Lauren C.:
Hello,
I want to match:
/path/
/path/123
/path/abc
but /path/?xxx should not be matched.
This works:
$ perl -le '$x="/path/abc"; print 1 if $x=~m{path/\w+}'
1
this works
> But it doesn't work for this case:
$ perl -le '$x="/path/"; print 1 if $x=~m{path/\w+}'
> it expects 1 returned.
Well, assuming you mean it shouldn't match as $x starts with a slash and
the RE doesn't - you're on the right path. The reason is, the match goes
anywhere, it is "unanchored" so Pe
2018-07-17 19:56:59 +0800 Lauren C.:
> Hello,
>
> I want to match:
>
> /path/
> /path/123
> /path/abc
>
> but /path/?xxx should not be matched.
>
> This works:
>
> $ perl -le '$x="/path/abc"; print 1 if $x=~m{path/\w+}'
> 1
>
>
> this works too:
>
> $ perl -le '$x="/path/?abc"; print 1 if
Hi!
I think, m{path/(\w+)?/?$} regex can solve your problem.
In general, to parse URL, you can use official regex from rfc3986 (see
Appendix B for rfc3986)
regex is
^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
$2 is protocol
$4 is host
$5 is path
$7 is query
$9 is fragment.
Ano
Hello,
I want to match:
/path/
/path/123
/path/abc
but /path/?xxx should not be matched.
This works:
$ perl -le '$x="/path/abc"; print 1 if $x=~m{path/\w+}'
1
this works too:
$ perl -le '$x="/path/?abc"; print 1 if $x=~m{path/\w+}'
But it doesn't work for this case:
$ perl -le '$x="/pa
10 matches
Mail list logo