4 ms·
// from appendix B of rfc 3986 (http://www.ietf.org/rfc/rfc3986.txt http://www.ietf.org/rfc/rfc3986.txt) '&^(([^:/?#]+):)?(//([^/?#]))?([^?#])(\?([^#]))?(#(.))
by IgorPartola 17y ago
// from appendix B of rfc 3986 (http://www.ietf.org/rfc/rfc3986.txt http://www.ietf.org/rfc/rfc3986.txt)
'&^(([^:/?#]+):)?(//([^/?#]))?([^?#])(\?([^#]))?(#(.))?&'
The above regular expression is meant to match URI's. Since almost anything can be a URI, the re also matches almost everything.
- patio11 17y agoYou know you have done too much work with regular expressions when you think "Hey, wait a second, that can't possibly work" and start trying to debug it in the Ruby console for 10 minutes prior to realizing "Oh, HN is italicizing it because of the asterixes it is silently stripping."
- deleted 17y ago[deleted]
- Karzyn 17y ago^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
- silentbicycle 17y agoThe article was about e-mail addresses. Here's a link to an RFC-compliant regular expression for matching valid e-mail addresses: http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html Despite that evil voice telling you "There is nothing Perl cannot do!" (http://www.bastichlabz.org/bastich/Strips/ba980225.gif http://www.bastichlabz.org/bastich/Strips/ba980225.gif), regular expressions alone are not sufficient for real parsing,