# Re: a regex

**URL:** <https://www.ruby-forum.com/t/re-a-regex/73847>\
**Category:** Ruby\
**Created:** [October 27, 2006, 3:33pm UTC](https://www.ruby-forum.com/t/re-a-regex/73847 "2006-10-27T15:33:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CameronS\_Gemma\_SUK](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/45deac/32.png) [@CameronS\_Gemma\_SUK](https://www.ruby-forum.com/u/CameronS_Gemma_SUK)\
**Post date:** [October 27, 2006, 3:33pm UTC](https://www.ruby-forum.com/t/re-a-regex/73847/1 "2006-10-27T15:33:38Z")

</div>

You can split it:

string = 2006%2F10%2Fasdfasdf

year, day, text = string.split(/%2F/)

Should give:  
year=2006  
day=10  
text=asdfasdf

The variables at the beginning are the names you give the different bits  
you want out of the string, and you pass the regex or character you want  
to split the string with. It’s useful for filenames where you can split  
on the .

There is probably a very elegant way of doing this recusively if you  
have more than 3 cariables to fish out. ( :

Hope this helps?!

Gem
