in reply to Splitting on escapable delimiter
#!/usr/bin/perl use strict; use warnings; while( my $ln = <DATA> ) { chomp( $ln ); my @flds = split( '@', $ln ); foreach ( @flds ) { if ( /(#*)/ ) { print "/$ln/ --> /$1/\n" if ( length( $1 ) % 2 ) == 1; } } } __DATA__ #@##@###@####@#####@ #@## ###@#### #####@
This results in:
Revised: This won't work for a string with no pound signs. You'd need to modify the length test to include || length( $1 ) == 0./#@##@###@####@#####@/ --> /#/ /#@##@###@####@#####@/ --> /###/ /#@##@###@####@#####@/ --> /#####/ /#@##/ --> /#/ /###@####/ --> /###/ /#####@/ --> /#####/
|
|---|