From: ts Date: 2002-04-17T00:35:46+09:00 Subject: [SoD] regexp SoD is an acronym for "Stupidity of the Day" :-) This is a mix between the P construct (??{ code }) and shared regexp. pigeon% cat b.rb #!./ruby re = /(?i:^\W*(?:(?

(.)\W*(?*p)\W*\1|)|(?(.)\W*(?*r)\W*\2|\W*.\W*))\W*$)/ [ "A man, a plan, a canal : Panama", "Satan, oscillate my metallic sonatas!", "Esope reste elu par cette crapule et se repose", "Tu l'as trop ecrase Cesar, ce port salut" ].each do |s| if re =~ s p $& end end re = /(?x:(?[^][(){}<>]+ | \((?*r)*\) | \[(?*r)*\] | \{(?*r)*\} | <(?*r)* >))/ [ "abc{abc[uvw](x)}xx(ab)" ].each do |s| s.scan(re) do |x,| p x end end pigeon% pigeon% b.rb "A man, a plan, a canal : Panama" "Satan, oscillate my metallic sonatas!" "Esope reste elu par cette crapule et se repose" "Tu l'as trop ecrase Cesar, ce port salut" "abc" "{abc[uvw](x)}" "xx" "(ab)" pigeon% Well, actually I've some problem with left-recursion :-) Guy Decoux