From: Robert Klemme Date: 2005-01-27T19:35:56+09:00 Subject: Re: RegEx help (small) "ts" schrieb im Newsbeitrag news:200501271020.j0RAKGL04736@moulon.inra.fr... > >>>>> "B" == Bil Kleb writes: > > B> gsub( /(?!\w)'(.*?)'/, '`\1\'' ) > > (?!) is a zero-width negative look-ahead > > > B> assert_equal( "isn't fool'd", "isn't fool'd".to_tex ) > > When the regexp engine is at this position (just before ') > > "isn't fool'd" > > ^ > | > > * it look if it don't have a word character (\w) : this is true because the > first next character is ' > > * then it look if it has ' : it's true and it match These seem to work: >> class String >> def to_tex >> gsub( /(?:\A|(?![\w']))'(.*?)'/, '`\\1\'' ) >> end >> end => nil >> "'single quotation'".to_tex => "`single quotation'" >> class String >> def to_tex >> gsub( /'((?:[^\\']|\\.)*)'/, '`\\1\'' ) >> end >> end => nil >> "'single quotation'".to_tex => "`single quotation'" But I dunno whether they fix all of your problems. Kind regards robert