On 10/02/2012 10:58 AM, ajay paswan wrote:
> Sam Duncan wrote in post #1078251:
>> On 10/02/2012 10:32 AM, ajay paswan wrote:
>>> How to sparse a string like:
>>>
>>> suppose input is str="<a>1</a><a>22</a><a>3</a>"
>>> I want str_a=["<a>1</a>","<a>22</a>","<a>3</a>"]
>>> How can I get str_a from str?
>>>
>> 1.9.3p125 :002 > str.scan /<a>\d+<\/a>/
>>    => ["<a>1</a>", "<a>22</a>", "<a>3</a>"]
>>
>> Sam
> What if: str="<a>kl1</a><a>22ik</a><a>3o</a>" ?
>
1.9.3p125 :002 > str.scan /<a>[[:alnum:]]+<\/a>/
  => ["<a>kl1</a>", "<a>22ik</a>", "<a>3o</a>"]

Ping pong

I think perhaps you should read up on regular expressions in Ruby =]

Sam