Context
Using Ruby I am parsing strings looking like this:
A type with an ID...
[Image=4b5da003ee133e8368000002]
[Video=679hfpam9v56dh800khfdd32]
...with between 0 and n additional options separated with @...
[Image=4b5da003ee133e8368000002@size:small]
[Image=4b5da003ee133e8368000002@size:small@media:true]
In this example:
[Image=4b5da003ee133e8368000002@size:small@media:true]
I want to retrieve:
- [Image=4b5da003ee133e8368000002@size:small@media:true]
- Image
- 4b5da003ee133e8368000002
- size:small
- media:true
Problem
Right now using this regex:
(\[([a-zA-Z]+)=([a-zA-Z0-9]+)(@[a-zA-Z]+:[a-zA-Z]+)*\])
I get...
- [Image=4b5da003ee133e8368000002@size:small@media:true]
- Image
- 4b5da003ee133e8368000002
- @media:true
What am I doing wrong? How can I get what I want?
PS: All the results are copied from http://rubular.com/ which is nice to debug regex. Please use it if it can help you help me :)
Edit : if it's impossible to get all options separated, how could I get this:
- [Image=4b5da003ee133e8368000002@size:small@media:true]
- Image
- 4b5da003ee133e8368000002
- @size:small@media:true