[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Ruby Regex

Sriram Varahan

4/9/2009 2:44:00 PM

Hello,


I am working on extracting some data from a file.
Sample data in the file are as follows:

Case 1: Direction abc,(xyz)
Case 2: Direction fet

I want to extract the content after Direction but before the comma(if
present).
The issue I am facing is that the comma is not always present.

Otherwise a reg exp like:

reg_exp = %r{Direction(.+),}

would have given me the content.
This would not work in the 2nd case.


How to account for both the conditions.
Any help would be appreciated...
--
Posted via http://www.ruby-....

4 Answers

Robert Klemme

4/9/2009 2:48:00 PM

0

On 09.04.2009 16:44, Sriram Varahan wrote:
> Hello,
>
>
> I am working on extracting some data from a file.
> Sample data in the file are as follows:
>
> Case 1: Direction abc,(xyz)
> Case 2: Direction fet
>
> I want to extract the content after Direction but before the comma(if
> present).
> The issue I am facing is that the comma is not always present.
>
> Otherwise a reg exp like:
>
> reg_exp = %r{Direction(.+),}
>
> would have given me the content.
> This would not work in the 2nd case.
>
>
> How to account for both the conditions.
> Any help would be appreciated...

/Direction\s+([^,]+)/

Cheers

robert

Sriram Varahan

4/9/2009 3:02:00 PM

0

Robert Klemme wrote:
> On 09.04.2009 16:44, Sriram Varahan wrote:
>> present).
>> How to account for both the conditions.
>> Any help would be appreciated...
>
> /Direction\s+([^,]+)/
>
> Cheers
>
> robert


Hey Robert,

Thanks a ton for ur help...
It worked...
--
Posted via http://www.ruby-....

Richard Steel

1/13/2012 9:45:00 AM

0

On Jan 12, 6:37 pm, 2849 Dead <d...@gone.com> wrote:
> On Thu, 12 Jan 2012 18:25:33 -0800, Richard Steel wrote:
> >>http://bedford-nh.patch.com/articles/conservative-activi...
> >> undercover-footage-at-nashua-polls
>
> >> AG Investigating Undercover Filming at Nashua Polls
>
> >> James O'Keefe, widely known as the undercover "pimp" who filmed a sting
> >> involving ACORN, takes issue with New Hampshire's lack of required ID
> >> at the polls. The state, in turn, is taking issue with his methods.

> > Meanwhile, you guys fret about Cher's "right" to say "fuck" on national
> > television.

> We've established that you'll say fuck when it suits you.

When did I deny that I would?

> Now, are you willing to commit voter fraud in order to show that it's
> technically possible?

No, because I'm not a Democrat?

> Will you be murdering anyone to show that's possible, too?

No, I leave that to Eric Holder and the Fast and Furious boys.

rfischer

1/15/2012 12:05:00 AM

0

Richard Steel <rsteel2525@aol.com> wrote:
>
>> http://bedford-nh.patch.com/articles/conservative-activi...
>> undercover-footage-at-nashua-polls
>
>> AG Investigating Undercover Filming at Nashua Polls
>
>> James O'Keefe, widely known as the undercover "pimp" who filmed a sting
>> involving ACORN, takes issue with New Hampshire's lack of required ID at
>> the polls. The state, in turn, is taking issue with his methods.
>
>Meanwhile, you guys fret about Cher's "right" to say "fuck" on
>national television.

It's always the religious reich who demand more censorship of TV. But
be a good little fascist and whine that whatever you do is somebody
else's fault.

--
Ray Fischer | None are more hopelessly enslaved than those who falsely believe they are free.
rfischer@sonic.net | Goethe