Skip to Main Content
Wyra?enia regularne. Receptury
book

Wyra?enia regularne. Receptury

by Jan Goyvaerts, Steven Levithan
May 2010
Intermediate to advanced content levelIntermediate to advanced
520 pages
17h 44m
Polish
Helion
Content preview from Wyra?enia regularne. Receptury

7.7. Weryfikacja poprawności adresów URL według ogólnych reguł

Problem

Chcemy sprawdzić, czy dany fragment tekstu zawiera prawidłowy adres URL, zgodny ze standardem RFC 3986.

Rozwiązanie

  • \A
    (# Schemat
     [a-z][a-z0-9+\-.]*:
     (# Serwer i ścieżka
      //
      ([a-z0-9\-._~%!$&'()*+,;=]+@)?               # Użytkownik
      ([a-z0-9\-._~%]+                             # Nazwany host
      |\[[a-f0-9:.]+\]                             # Host IPv6
      |\[v[a-f0-9][a-z0-9\-._~%!$&'()*+,;=:]+\])   # Host IPvFuture
      (:[0-9]+)?                                   # Port
      (/[a-z0-9\-._~%!$&'()*+,;=:@]+)*/?           # Ścieżka
     |# Ścieżka bez serwera
      (/?[a-z0-9\-._~%!$&'()*+,;=:@]+(/[a-z0-9\-._~%!$&'()*+,;=:@]+)*/?)?
     )
    |# Względny adres URL (bez schematu i serwera)
     (# Ścieżka względna
      [a-z0-9\-._~%!$&'()*+,;=@]+(/[a-z0-9\-._~%!$&'()*+,;=:@]+)*/?
     |# Ścieżka bezwzględna (/[a-z0-9\-._~%!$&'()*+,;=:@]+)+/? ) ) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mikrousługi oparte na zdarzeniach

Mikrousługi oparte na zdarzeniach

Adam Bellemare

Publisher Resources

ISBN: 9781457167003