Need regex help (or bug in match) 
Author Message
 Need regex help (or bug in match)

Hi

I seem to be having a problem with match and I can't figure
it out. It's either a bug or I am doing something stupid
and can't see the forest for the trees.

Can regex guru help me out here?
Thanks

 FETCH_DATA_HDR = /\[([^]]*)\]/

 PUSH_DATA_HDR = Proc.new { |line|
   m = FETCH_DATA_HDR.match(line.strip)
   a = m[1].split(/\s*,\s*/, 2)
   hdr = []
   p a
   hdr << {:X_VAR_NOM => a.shift}
   p a
   p a[0]
   s = /^([^(]*)\(/.match(a[0])
   puts /Vg/ =~ a[0]  #=> nil
   p s[1]             #=> Vg  # How can this match Vg when /Vg/ =~ a[0] == nil?
 }

 line = "[Vgs, Id(Vbs=0.0E+00), Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0]"
 PUSH_DATA_HDR.call(line)

--
Jim Freeze
----------
You cannot kill time without injuring eternity.



Sun, 31 Jul 2005 23:11:16 GMT  
 Need regex help (or bug in match)
Hi --

Quote:

> Hi

> I seem to be having a problem with match and I can't figure
> it out. It's either a bug or I am doing something stupid
> and can't see the forest for the trees.

> Can regex guru help me out here?
> Thanks

>  FETCH_DATA_HDR = /\[([^]]*)\]/

>  PUSH_DATA_HDR = Proc.new { |line|
>    m = FETCH_DATA_HDR.match(line.strip)
>    a = m[1].split(/\s*,\s*/, 2)
>    hdr = []
>    p a
>    hdr << {:X_VAR_NOM => a.shift}
>    p a
>    p a[0]
>    s = /^([^(]*)\(/.match(a[0])
>    puts /Vg/ =~ a[0]  #=> nil
>    p s[1]             #=> Vg  # How can this match Vg when /Vg/ =~ a[0] == nil?
>  }

>  line = "[Vgs, Id(Vbs=0.0E+00), Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0]"
>  PUSH_DATA_HDR.call(line)

I get Id, not Vg, for s[1].

David

--
David Alan Black


Web:  http://pirate.shu.edu/~blackdav



Sun, 31 Jul 2005 23:18:16 GMT  
 Need regex help (or bug in match)

Quote:

> I get Id, not Vg, for s[1].

% cat test.rb
FETCH_DATA_HDR = /\[([^]]*)\]/

PUSH_DATA_HDR = Proc.new { |line|
  m = FETCH_DATA_HDR.match(line.strip)
  a = m[1].split(/\s*,\s*/, 2)
  hdr = []
  p a
  hdr << {:X_VAR_NOM => a.shift}
  p a
  p a[0]
  s = /^([^(]*)\(/.match(a[0])
  puts /Vg/ =~ a[0]
  p s[1]  #=> Vg  # How can this match Vg when /Vg/ =~ a[0] == nil?

Quote:
}

line = "[Vgs, Id(Vbs=0.0E+00), Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0]"
PUSH_DATA_HDR.call(line)

line2 = "[Id(Vbs=0.0E+00), Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0]"
PUSH_DATA_HDR.call(line2)

% ruby test.rb
["Vgs", "Id(Vbs=0.0E+00), Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0"]
["Id(Vbs=0.0E+00), Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0"]
"Id(Vbs=0.0E+00), Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0"
nil
"Vg"
["Id(Vbs=0.0E+00)", "Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0"]
["Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0"]
"Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0"
nil
"Id"
% ruby -v
ruby 1.7.3 (2002-12-17) [sparc-solaris2.8]

--
Jim Freeze
----------
May Euell Gibbons eat your only copy of the manual!



Sun, 31 Jul 2005 23:50:35 GMT  
 Need regex help (or bug in match)

Quote:

> Hi --

> I get Id, not Vg, for s[1].

I just checked 1.7.3 on FreeBSD. Gives Id.

--
Jim Freeze
----------
Swahili, n.:
        The language used by the National Enquirer to print their
retractions.
                -- Johnny Hart



Sun, 31 Jul 2005 23:52:43 GMT  
 Need regex help (or bug in match)
Hi --

Quote:


> > Hi --

> > I get Id, not Vg, for s[1].

> I just checked 1.7.3 on FreeBSD. Gives Id.

I've been checking a few other versions, and I can't duplicate the Vg
result either.  It must be snapshot-specific or something.

David

--
David Alan Black


Web:  http://pirate.shu.edu/~blackdav



Sun, 31 Jul 2005 23:58:30 GMT  
 Need regex help (or bug in match)

Quote:


> > Hi --

> > I get Id, not Vg, for s[1].

> I just checked 1.7.3 on FreeBSD. Gives Id.

also on

  ~ > uname -mrsp
  Linux 2.2.14-5.0 i686 unknown

  > ruby -v
  ruby 1.8.0 (2003-01-30) [i686-linux]

that looks like a bug.

-a

--

 ====================================
 | Ara Howard
 | NOAA Forecast Systems Laboratory
 | Information and Technology Services
 | Data Systems Group
 | R/FST 325 Broadway
 | Boulder, CO 80305-3328

 | Phone:  303-497-7238
 | Fax:    303-497-7259
 ====================================



Mon, 01 Aug 2005 00:06:14 GMT  
 Need regex help (or bug in match)

J> % ruby -v
J> ruby 1.7.3 (2002-12-17) [sparc-solaris2.8]

 It's broken your solaris

nasun% cat b.rb
#!./ruby -v
FETCH_DATA_HDR = /\[([^]]*)\]/

PUSH_DATA_HDR = Proc.new { |line|
  m = FETCH_DATA_HDR.match(line.strip)
  a = m[1].split(/\s*,\s*/, 2)
  hdr = []
  p a
   hdr << {:X_VAR_NOM => a.shift}
  p a
  p a[0]
  s = /^([^(]*)\(/.match(a[0])
  puts /Vg/ =~ a[0]
  p s[1]  #=> Vg  # How can this match Vg when /Vg/ =~ a[0] == nil?

Quote:
}

line = "[Vgs, Id(Vbs=0.0E+00), Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0]"
PUSH_DATA_HDR.call(line)

line2 = "[Id(Vbs=0.0E+00), Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0]"
PUSH_DATA_HDR.call(line2)
nasun%

nasun% b.rb
ruby 1.7.3 (2002-12-04) [sparc-solaris2.8]
./b.rb:13: warning: ambiguous first argument; make sure
["Vgs", "Id(Vbs=0.0E+00), Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0"]
["Id(Vbs=0.0E+00), Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0"]
"Id(Vbs=0.0E+00), Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0"
nil
"Id"
["Id(Vbs=0.0E+00)", "Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0"]
["Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0"]
"Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0"
nil
"Id"
nasun%

Guy Decoux



Mon, 01 Aug 2005 00:11:51 GMT  
 Need regex help (or bug in match)

Quote:
>So: is there a process by which we can identify *exactly* what all the
>missing modules are?  And then write them? :-)

Caveat: I'm just coming to Ruby from Perl. I get paid to write and maintain
Perl. I'm pretty aware, I think, of the limitations of Perl (don't get me
started on it!) and the CPAN and don't know enough about Ruby yet to take
myself seriously in this camp.

Having said all that ... :-)

First off, a good place to look for modules that are candidates for
duplication are:

   The perl core
      http://www.*-*-*.com/

   The "most downloaded" list for CPAN search
      http://www.*-*-*.com/

The latter is a very imperfect snapshot, but not a bad place to get a good
idea of what people are bothering to update: the database stuff, LWP,
libnet, the mail tools, compression, date-related stuff, etc.

I was also, I have to admit, disappointed to follow this thread in the
archive and see all the "CPAN? We don't want no steeeeekin' CPAN!"
responses. Yes, there's a lot of {*filter*}on the CPAN, and you'll occasionally
get into trouble with dependencies and such.

But for all the elegance and ease of Ruby, lots of problems are inherently
*hard* (or just incredibly painful) to code well (meaning fast, complete,
taking exceptions into account, etc) no matter what your programming
environment. If someone creates a good module, the question should be, "How
can we lower the bar for the effort it takes to get this great module out
to the public?" In that respect, I think the CPAN is wildly successful.

The ability for me to fire up a CPANPLUS shell and search for "Crypt" or
"Statistics" and come up with instant solutions to my problems most of the
time is incredibly appealing. A well-defined, well-regulated, and empty
archive doesn't do anyone any good.

After years of Perl, you can imagine how e{*filter*}d I am to start using Ruby
for my daily work. But CPAN is a hard drug to give up. I can't even imagine
how much stuff I've done over the past few years wouldn't have been worth
the effort if I hadn't been able to cobble together pieces from the CPAN
that got me 90% of the way there.

Bill Dueber * Ph.D. candidate, Instructional Systems Technology, IU *
Graduate Assistant, IU Bloomington Educational Studies and Testing



Mon, 01 Aug 2005 00:35:40 GMT  
 Need regex help (or bug in match)

Quote:
----- Original Message -----


Sent: Wednesday, February 12, 2003 10:35 AM
Subject: Re: Can we attack the 'not enough libraries' thing straight on?

> Caveat: I'm just coming to Ruby from Perl. I get paid to write and
maintain
> Perl. I'm pretty aware, I think, of the limitations of Perl (don't get me
> started on it!) and the CPAN and don't know enough about Ruby yet to take
> myself seriously in this camp.

Thanks for your comments, Bill...

Just to clarify a little: No one questions the need for a
central repository. Perl and python both have theirs, and
so does Ruby.

There are at least three issues in my mind:

1. The RAA does need to be improved in terms of usability
(and has improved greatly over the past weeks).

2. It also needs more content.

3. Many people feel that (in connection with #1) there
should be a way to browse offline, automatically install
packages, auto-install dependencies, and so on. I have
no problem with that.

Quote:
> The latter is a very imperfect snapshot, but not a bad place to get a good
> idea of what people are bothering to update: the database stuff, LWP,
> libnet, the mail tools, compression, date-related stuff, etc.

I suggest you browse the RAA and let us know what
you think is missing. (That's not any kind of
snotty sarcasm, just an earnest request.)

By the way: Much of our TFGF (Taken-For-Granted Functionality)
is in the core and the standard libraries rather than in
add-ons.

For example, Time is in the core and Date covers most of the
other needed functionality. The Thread class is in the core
(non-native only right now). SMTP and POP3 and CGI and HTTP
and FTP and so on are in the standard libraries (installed
when Ruby is installed).

Quote:
> I was also, I have to admit, disappointed to follow this thread in the
> archive and see all the "CPAN? We don't want no steeeeekin' CPAN!"
> responses. Yes, there's a lot of {*filter*}on the CPAN, and you'll occasionally
> get into trouble with dependencies and such.

Over the (very long) lifetime of that discussion -- not just
its latest incarnation -- there hasn't been much of that.
90% of what I've heard about CPAN is positive. I don't know
from my own experience, as I'm not a real Perler.

Quote:
> But for all the elegance and ease of Ruby, lots of problems are inherently
> *hard* (or just incredibly painful) to code well (meaning fast, complete,
> taking exceptions into account, etc) no matter what your programming
> environment. If someone creates a good module, the question should be,
"How
> can we lower the bar for the effort it takes to get this great module out
> to the public?" In that respect, I think the CPAN is wildly successful.

[snip again]

I gather then that you come down heavily in favor of
the "universal smart installer."

I'd love to see a standard emerge and then become
universally used. Right now we have raainstall and
rpkg, neither of which I'm familiar with. As far as
I know, these are nowhere near universal nor are
they compatible with each other. There are probably
others also.

But as Piet Hein said:

  Put up in a place where it's easy to see
  The cryptic admonishment: TTT.
  When you feel how depressingly slowly you climb,
  It's well to remember that Things Take Time.

Hal



Mon, 01 Aug 2005 06:10:06 GMT  
 Need regex help (or bug in match)

Quote:

> By the way: Much of our TFGF (Taken-For-Granted Functionality)
> is in the core and the standard libraries rather than in
> add-ons.

And is this the call for Ruby Micro Edition, or 2.0, bytecode and
performance are the prerequisites for that? :)

Or that's packaging part? (but then, minus-deps come into play)

--

  ------ Linux.Kiev http://www.linux.kiev.ua/



Mon, 01 Aug 2005 06:17:56 GMT  
 Need regex help (or bug in match)

Quote:


> > By the way: Much of our TFGF (Taken-For-Granted Functionality)
> > is in the core and the standard libraries rather than in
> > add-ons.

> And is this the call for Ruby Micro Edition, or 2.0, bytecode and
> performance are the prerequisites for that? :)

matz has already said that Ruby without Array, Hash and String (to name
a few) is no longer Ruby.

Quote:
> Or that's packaging part? (but then, minus-deps come into play)

--
 _           _                            
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
        Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

#if _FP_W_TYPE_SIZE < 64
#error "Only stud muffins allowed, schmuck."
#endif
        -- linux/arch/sparc64/quad.c



Mon, 01 Aug 2005 06:35:24 GMT  
 Need regex help (or bug in match)

Quote:

> > And is this the call for Ruby Micro Edition, or 2.0, bytecode
> > and performance are the prerequisites for that? :)
> matz has already said that Ruby without Array, Hash and String
> (to name a few) is no longer Ruby.

Those differ.  Building blocks and fancy extensions do differ.
I'm just wondering about "perl-5.8-like-problem" and hoping it
won't turn up in some form here.

--

  ------ Linux.Kiev http://www.linux.kiev.ua/



Mon, 01 Aug 2005 06:44:58 GMT  
 Need regex help (or bug in match)

Quote:

> Over the (very long) lifetime of that discussion -- not just
> its latest incarnation -- there hasn't been much of that.
> 90% of what I've heard about CPAN is positive. I don't know
> from my own experience, as I'm not a real Perler.

Well, I'm saying negative things.  CPAN (the Module) has given me too many
problems over the last year or so.  It seems to work equally badly on all
platforms.  I hope I'll never have to deal with it again.

Quote:
> I gather then that you come down heavily in favor of
> the "universal smart installer."

> I'd love to see a standard emerge and then become
> universally used. Right now we have raainstall and
> rpkg, neither of which I'm familiar with. As far as
> I know, these are nowhere near universal nor are
> they compatible with each other. There are probably
> others also.

I don't quite agree.  I really don't want another package manager for Ruby
add-ons that doesn't play nicely with the package manager for the system.  
I've spent too many years doing sys admin in large data centers and have
seen too many problems when each box is configured by hand.  I'd really
like to see .rpm, .deb, etc. packages generated.

I know it's an unpopular view, but I'm sticking to it.

-- Matt



Mon, 01 Aug 2005 07:34:48 GMT  
 Need regex help (or bug in match)

Quote:
----- Original Message -----


Sent: Wednesday, February 12, 2003 5:34 PM
Subject: Re: Can we attack the 'not enough libraries' thing straight on?

> Well, I'm saying negative things.  CPAN (the Module) has given me too many
> problems over the last year or so.  It seems to work equally badly on all
> platforms.  I hope I'll never have to deal with it again.

Do you think the problems are (in principle) fixable if we
implement a Ruby tool similar in spirit?

Quote:
> > I gather then that you come down heavily in favor of
> > the "universal smart installer."

> > I'd love to see a standard emerge and then become
> > universally used. Right now we have raainstall and
> > rpkg, neither of which I'm familiar with. As far as
> > I know, these are nowhere near universal nor are
> > they compatible with each other. There are probably
> > others also.

> I don't quite agree.  I really don't want another package manager for Ruby
> add-ons that doesn't play nicely with the package manager for the system.
> I've spent too many years doing sys admin in large data centers and have
> seen too many problems when each box is configured by hand.  I'd really
> like to see .rpm, .deb, etc. packages generated.

> I know it's an unpopular view, but I'm sticking to it.

I can see that. Is there some kind of compromise
possible?

For example, can we divide this into three issues?
1. the repository; 2. the data format; 3. the install
tool.

Bear in mind here that while I have extensive UNIX
background, I'm fairly Linux-ignorant.

Supposing we stored alternative packages in the RAA
(rpm, deb, etc.) Would the respective tools be smart
enough to go to the RAA to get the packages? Or would
we simply download and manually run the tool?

Or could the RAA installer be smart enough to invoke
the system package manager?

In short, is there some not-too-unacceptable way to
please everybody?

Hal



Mon, 01 Aug 2005 07:57:10 GMT  
 
 [ 18 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Possible regex match bug (re module)

2. SioModule bug/fix (regex.match)

3. SioModule bug/fix (regex.match)

4. Need regex to match "^\n"

5. Store regex match in a variable

6. regex matching and text moving

7. Regex \w does not match underscore

8. regex: how to limit pattern match to first occurance

9. RegEx ASCII character matching

10. RegEx help need!

11. Scope of regex match $variables

12. How to Convert String to Regex to Perform Exact Match

 

 
Powered by phpBB® Forum Software