How to get the certain segment of a URL using regex? -


say url http://aa/bb/cc. "aa" in segment 1, "bb" in 2 , "cc" in 3. how regex extract given number of segment? (so \2, \3 refers part of url.)

try regex:

http:/(?:/([^/]+))+ 

explaination:

(subexpression) captures matched subexpression , assigns zero-based ordinal number.

(?:subexpression) defines noncapturing group.

+ matches previous element 1 or more times.

[^character_group] negation: matches single character not in character_group.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -