Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Regular expression for matching URIs
- *
- * Significantly more accurate than any other method I've come across,
- * including the built in PHP methods.
- *
- * @author ChristianF
- * @link www.fagsoft.no
- * @licence http://creativecommons.org/licenses/by-sa/3.0/
- */
- $RegExp = '#^(?:(?:(?:f|ht)tps?|dchub|sftp|steam)://)?'.
- // Username-password combos.
- '(?:\\w+(?::\\w+)?@)?'.
- // Domain or IP address
- '(?:((?:[\\w\\pL][\\w\\pL-]*(?<!\\-)\\.)+[a-z\\pL]{2,5})(?::\\d{1,5})?'.
- '|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))'.
- // URL Path
- '((?:(?<!/)/(?:\w(?:%[a-f\\d]{2}|[\\w\\., -])*)*)+(?:(?:\\.\\w{1,6})?'.
- // URL param
- '(\\?(?:(?:%[a-f\\d]{2}|[\\w\\.-])+=(?:%[a-f\\d]{2}|[\\w\\.-])+)(?:&(?:%[a-f\\d]{2}|[\\w\\.-])+(?:=(?:%[a-f\\d]{2}|[\\w\\.-])+)?)*&?)?'.
- ')?)?\\z#ui';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement