Regular expression question

My pattern works fine in VI. Back slash before (,) and | is needed to
assign special meaning to them.

From: Shannon Fang [mailto:xrfang@hotmail.com]
Sent: Tuesday, December 03, 2002 6:22 PM
To: ruby-talk ML
Subject: Re: Regular expression question

line !~ /\(^#\)\|\(^[\s\t]*$\)/

I think you just need to use ( not (, I suppose it should be

line !~ /^#|^\s*$/

if you don’t need to reference I think no () is needed. And \s should
include whitespace and \t?

I replaced already it to \S so the pattern now is
(^#)|(^\S*$)

Nevertheless it doesn’t work yet:-)

···

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

Shannon


Protect your PC - get McAfee.com VirusScan Online
Antivirus, VPN, Identity & Privacy Protection | McAfee

My pattern works fine in VI. Back slash before (,) and | is needed to
assign special meaning to them.

This is the opposite in ruby, you use \ to say that this character don't
have a special meaning.

Guy Decoux

beware that regex in VI are different of regex in Ruby
with Ruby, you have to backslash ( to have NO regex sens (only caractere
sens),
with VI, you have to backslash ( to have meaning (only regex sens)
hope this help

···

On Tue, 2002-12-03 at 17:28, Roman Rytov wrote:

My pattern works fine in VI. Back slash before (,) and | is needed to
assign special meaning to them.

-----Original Message-----
From: Shannon Fang [mailto:xrfang@hotmail.com]
Sent: Tuesday, December 03, 2002 6:22 PM
To: ruby-talk ML
Subject: Re: Regular expression question

line !~ /\(^#\)\|\(^[\s\t]*$\)/

I think you just need to use ( not (, I suppose it should be

line !~ /^#|^\s*$/

if you don’t need to reference I think no () is needed. And \s should
include whitespace and \t?

I replaced already it to \S so the pattern now is
(^#)|(^\S*$)

Nevertheless it doesn’t work yet:-)

Shannon


Protect your PC - get McAfee.com VirusScan Online
Antivirus, VPN, Identity & Privacy Protection | McAfee


Ludo coquelle@enib.fr
ENIB/LI2

Well, Ruby regexps are not VI regexps. Look similar to some extend, but
still different. VI implements BRE, and Ruby is closer to ERE (like in awk,
egrep, etc.). Plus a lot of other nice features.

···

----- Original Message -----
From: “Roman Rytov” rrytov@entopia.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Tuesday, December 03, 2002 8:28 AM
Subject: Re: Regular expression question

My pattern works fine in VI. Back slash before (,) and | is needed to
assign special meaning to them.

-----Original Message-----
From: Shannon Fang [mailto:xrfang@hotmail.com]
Sent: Tuesday, December 03, 2002 6:22 PM
To: ruby-talk ML
Subject: Re: Regular expression question

line !~ /\(^#\)\|\(^[\s\t]*$\)/

I think you just need to use ( not (, I suppose it should be

line !~ /^#|^\s*$/

if you don’t need to reference I think no () is needed. And \s should
include whitespace and \t?

I replaced already it to \S so the pattern now is
(^#)|(^\S*$)

Nevertheless it doesn’t work yet:-)

Shannon


Protect your PC - get McAfee.com VirusScan Online
Antivirus, VPN, Identity & Privacy Protection | McAfee