I need to parse an extremely complex string of characters to extract a particular section of it, which contains a foreign key to a database (the snippet comes from a product called Interspire Email Marketer and contains some weird logic to filter a contact list).
The string in question is as follows (yes, I realize it's extremely weird. That's how the system stores it):
a:2:{s:5:"Lists";a:1:{i:0;s:1:"6";}s:5:"Rules";a:1:{i:0;a:3:
{s:4:"type";s:5:"group";s:9:"connector";s:3:"and";s:5:"rules";a:1:{i:0;a:3:
{s:4:"type";s:4:"rule";s:9:"connector";s:3:"and";s:5:"rules";a:2:
{s:8:"ruleName";s:3:"100";s:12:"ruleOperator";s:7:"isempty";}}}}}}
The part I need is {i:0;s:1:"<here>";}
but it can be more than just a single character. How can I parse this weird string and extract the number I need with Ruby?