From: Antonin AMAND Date: 2006-03-10T20:14:39+09:00 Subject: Re: Small regexp question -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 francisrammeloo@hotmail.com a �crit : > Hi all, > > I am writing some refactoring code for a C++ project. > > I need to change: > > class MyClass > { > ... > } > > to: > > class IMP_EXP MyClass > { > ... > } > > The pattern I used to find a class definition line is: > > line =~ /^\s*class\s+(\w+)/ > > But I want to exclude forward class declarations ( class MyClass; ) > > So I changed my pattern to: > > line =~ /^\s*class\s+(\w+)\s*[^;]/ --> don't match if line ends > with ";" > > But it doesn't work... Why? > > I ended up using: if line !~ /;/ and line =~ /^\s*class\s+(\w+)/ > > Hints? > > Any help will be appreciated, > Best regards, > > Francis > > puts "ok" if "class MyClass;".match(/^\s*class\s+(\w+)\s*[^;]/) => "ok" it works for me. The problem may be somewhere else. Antonin. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEEV+IrvKyD2MLOwsRAoY0AJ4nPyzvD8ZrfGviBWBmWewOu6GuQgCfcFSG LwkwT0uAahhQbOg+7/eKwwI= =OzYv -----END PGP SIGNATURE-----