From: Ruby Bucket on
/[^\+]*\+\+\(\(([0-9]+)\)\)\+\+.*/


On Nov 30, 2009, at 9:07 PM, J. mp wrote:

> Hi,
>
> I really can't figure out how regular expressions work, and since I
> don't use them frequently is easier to ask...
>
> I have the follwow string
>
> ++((100))++askjasdjksjdkasdkjk++((200))++skdjsjd
>
> I need a reg expression that extracts only the first number inside the
> first ++(( ))++ and ignore the rest..., in this case I need to return
> 100
>
>
> thanks
> --
> Posted via http://www.ruby-forum.com/.
>


From: Liu Lantao on
[Note: parts of this message were removed to make it a legal post.]

extractor = Regexp.new('\+\+\(\((\d+)\)\)\+\+')
extractor.match will extract all the ++(123)++ like parts and extract all
123s into an array,
if the string start with ++, try
^\+\+\(\((\d+)\)\)\+\+

On Tue, Dec 1, 2009 at 10:07 AM, J. mp <joaomiguel.pereira(a)gmail.com> wrote:

> Hi,
>
> I really can't figure out how regular expressions work, and since I
> don't use them frequently is easier to ask...
>
> I have the follwow string
>
> ++((100))++askjasdjksjdkasdkjk++((200))++skdjsjd
>
> I need a reg expression that extracts only the first number inside the
> first ++(( ))++ and ignore the rest..., in this case I need to return
> 100
>
>
> thanks
> --
> Posted via http://www.ruby-forum.com/.
>
>


--
Liu Lantao
College of Information Science and Technology, Beijing Normal University
EMAIL: liulantao ( at ) gmail ( dot ) com ;
WEBSITE: http://www.liulantao.com/ .
------

From: Marnen Laibow-Koser on
Ruby Bucket wrote:
> /[^\+]*\+\+\(\(([0-9]+)\)\)\+\+.*/

Not quite. Anyway, don't spoon-feed the lazy. :)

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
marnen(a)marnen.org
--
Posted via http://www.ruby-forum.com/.