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.

Hi –

···

On Thu, 13 Feb 2003, Jim Freeze wrote:

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
home: dblack@candle.superlink.net
work: blackdav@shu.edu
Web: http://pirate.shu.edu/~blackdav

% 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?
}

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]

···

On Thursday, 13 February 2003 at 0:18:16 +0900, dblack@candle.superlink.net wrote:

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


Jim Freeze

May Euell Gibbons eat your only copy of the manual!

I just checked 1.7.3 on FreeBSD. Gives Id.

···

On Thursday, 13 February 2003 at 0:18:16 +0900, dblack@candle.superlink.net wrote:

Hi –

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


Jim Freeze

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

Hi –

···

On Thu, 13 Feb 2003, Jim Freeze wrote:

On Thursday, 13 February 2003 at 0:18:16 +0900, dblack@candle.superlink.net wrote:

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
home: dblack@candle.superlink.net
work: blackdav@shu.edu
Web: http://pirate.shu.edu/~blackdav

% ruby -v
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?
}

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

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

···

On Thu, 13 Feb 2003, Jim Freeze wrote:

On Thursday, 13 February 2003 at 0:18:16 +0900, dblack@candle.superlink.net wrote:

====================================

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ahoward@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================

A thousand years ago (Jan 23rd 2003), dblack wrote:

So: is there a process by which we can identify exactly what all the
missing modules are? And then write them? :slight_smile:

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 … :slight_smile:

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

The perl core
http://theoryx5.uwinnipeg.ca/CPAN/perl/

The “most downloaded” list for CPAN search
http://theoryx5.uwinnipeg.ca/CPAN/stats.html

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 crap 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 excited 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

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.

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).

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 crap 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

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

···

----- Original Message -----
From: “Bill Dueber” wdueber@indiana.edu
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Wednesday, February 12, 2003 10:35 AM
Subject: Re: Can we attack the ‘not enough libraries’ thing straight on?

from my own experience, as I’m not a real Perler.

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

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

···

On Thu, Feb 13, 2003 at 07:10:06AM +0900, Hal E. Fulton wrote:

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


---- WBR, Michael Shigorin mike@altlinux.ru
------ Linux.Kiev http://www.linux.kiev.ua/

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.

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

···

On Thu, 13 Feb 2003, Hal E. Fulton wrote:

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.

···

On Thu, Feb 13, 2003 at 07:35:24AM +0900, Mauricio Fern?ndez wrote:

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


---- WBR, Michael Shigorin mike@altlinux.ru
------ Linux.Kiev http://www.linux.kiev.ua/

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?

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

···

----- Original Message -----
From: “Matt Lawrence” matt@black-bart.net
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Wednesday, February 12, 2003 5:34 PM
Subject: Re: Can we attack the ‘not enough libraries’ thing straight on?

From: “Matt Lawrence” matt@black-bart.net

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?

Maybe,

[snip]

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

Sure.

For example, can we divide this into three issues?

  1. the repository; 2. the data format; 3. the install
    tool.

Absolutely.

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?

Some of tools will need to be told where to look and are then smart enough
to go get the packages. Other package tools don’t work quite so nicely
over the Internet.

I suggest that #2 above be in an easy to use format that contains all of
the necessary information for #3 to be the step that builds the various
packages (or this could be skipped if doing a raw RAA install). One big
advantage of this is that different people could write the tool for each
package format.

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

Bad idea. I already run synaptic on top of apt on top of rpm on most of
my systems. Actually, I run apt-get on top of rpm most of the time and
synaptic when I want to browse with a GUI. Another layer could be a mess.

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

I hope so.

– Matt

···

On Thu, 13 Feb 2003, Hal E. Fulton wrote:

----- Original Message -----

Ummm… but why?

Let’s wave in perl’s direction: CPAN doesn’t provide rpms or
debs, it provides tarballs and the former are the trouble (or
pride) of distributions. The same with *BSD and so on.

It’s just as different as coding and architecturing.

Yes?

···

On Thu, Feb 13, 2003 at 08:57:10AM +0900, Hal E. Fulton wrote:

Supposing we stored alternative packages in the RAA (rpm, deb,


---- WBR, Michael Shigorin mike@altlinux.ru
------ Linux.Kiev http://www.linux.kiev.ua/

For example, can we divide this into three issues?

  1. the repository; 2. the data format; 3. the install
    ^^^^^^^^^^^^^^^
    Of the module information (inside the tarball) or of the repository?
    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?

I don’t think we should be doing the packages ourselves, it’s a PITA.

Imagine that we create a standard module information format
included inside each and every module tarball (and even checked w/ a
script when updated) that would have all the information on how to
install it (and leaving ‘policy’ decisions to the final systems).
Now each system could have a tool to generate a package in its preferred
format by tailoring the module to its policies. Finally the module would
be installed by the system package manager.

There’s no point in writing the next APT. APT is the best APT around for
Debian (and some others :-).

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?

To summarize, separating module tarball creation from ‘specialization’
for each system in the form of the package.

···

On Thu, Feb 13, 2003 at 08:57:10AM +0900, Hal E. Fulton wrote:


_ _

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

Whoa…I did a ‘zcat /vmlinuz > /dev/audio’ and I think I heard God…
– mikecd on #Linux