
scrpnsanctuary
Novice
Jun 9, 2009, 11:19 AM
Post #8 of 9
(11147 views)
|
Re: [KevinR] expression for pulling domains out of URLs
[In reply to]
|
Can't Post
|
|
Got it:
The regular expression: (?-imsx:m,(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?,) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- m, 'm,' ---------------------------------------------------------------------- (?: group, but do not capture (optional (matching the most amount possible)): ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- [^:/?#]+ any character except: ':', '/', '?', '#' (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- : ':' ---------------------------------------------------------------------- )? end of grouping ---------------------------------------------------------------------- (?: group, but do not capture (optional (matching the most amount possible)): ---------------------------------------------------------------------- // '//' ---------------------------------------------------------------------- ( group and capture to \2: ---------------------------------------------------------------------- [^/?#]* any character except: '/', '?', '#' (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \2 ---------------------------------------------------------------------- )? end of grouping ---------------------------------------------------------------------- ( group and capture to \3: ---------------------------------------------------------------------- [^?#]* any character except: '?', '#' (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \3 ---------------------------------------------------------------------- (?: group, but do not capture (optional (matching the most amount possible)): ---------------------------------------------------------------------- \? '?' ---------------------------------------------------------------------- ( group and capture to \4: ---------------------------------------------------------------------- [^#]* any character except: '#' (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \4 ---------------------------------------------------------------------- )? end of grouping ---------------------------------------------------------------------- (?: group, but do not capture (optional (matching the most amount possible)): ---------------------------------------------------------------------- # '#' ---------------------------------------------------------------------- ( group and capture to \5: ---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \5 ---------------------------------------------------------------------- )? end of grouping ---------------------------------------------------------------------- , ',' ---------------------------------------------------------------------- ) end of grouping ---------------------------------------------------------------------- That actually makes sense to me after reading through it with a nice explanation, lol. ---------- The vastness of what we know is only surpassed by the vastness of what we don't.
|