[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Regular expression help

Jim flip

4/17/2007 2:08:00 PM

I have a line such as:

#define BLAH 10

or

#include "BLAH.h"

and I'm going around in circles trying to just get the 'include' or
'define' bit...anyone can help me?

Thanks
Bob.

--
Posted via http://www.ruby-....

4 Answers

Peter Szinek

4/17/2007 2:14:00 PM

0

Guest wrote:
> I have a line such as:
>
> #define BLAH 10
>
> or
>
> #include "BLAH.h"
>
> and I'm going around in circles trying to just get the 'include' or
> 'define' bit...anyone can help me?

line.scan(/(#.+?) /)[0][0]

HTH,
Peter
__
http://www.rubyra... :: Ruby and Web2.0 blog
http://s... :: Ruby web scraping framework
http://rubykitch... :: The indexed archive of all things Ruby

Martin DeMello

4/17/2007 2:19:00 PM

0

On 4/17/07, Guest <james@dimsum.tv> wrote:
> I have a line such as:
>
> #define BLAH 10
>
> or
>
> #include "BLAH.h"
>
> and I'm going around in circles trying to just get the 'include' or
> 'define' bit...anyone can help me?

Not quite sure what you mean - could you show some example of using
this, and the expected output?

martin

Robert Klemme

4/17/2007 2:39:00 PM

0

On 17.04.2007 16:08, Guest wrote:
> I have a line such as:
>
> #define BLAH 10
>
> or
>
> #include "BLAH.h"
>
> and I'm going around in circles trying to just get the 'include' or
> 'define' bit...anyone can help me?

>> ["#define BLAH 10", '#include "BLAH.h"'].map {|s| s[/^#(\w+)/, 1]}
=> ["define", "include"]

HTH

robert

Ara.T.Howard

4/17/2007 2:51:00 PM

0