I'm sorry I'm pretty noob with regex since long time.
How can I get from this kind of string /projects/myproject/, the 2 following elements (projects , myproject) ?
Output :
print group1 : 'projects'
print group2 : 'myproject'
Thanks
my_str = "/projects/myproject/"
matches = re.findall("/(.+?)/(.+)/",my_str)
print matches #prints ['projects','myproject']
matches is an array of strings that the regex matched. Not an array of arrays. And, can you show us the string you are matching against?matches[0] is what you are after. You can access your matches like matches[0][0] and matches[0][1]
parse_urlfunction. If you're using Perl, you want theURImodule. If you're using Ruby, use theURImodule.