Of course this will not work if there are embedded spaces in the path names.use strict; my @input = split /\n/, ' -IE:\david\nbssbts\btsc\bld -IE:\david\nbsscis\dcsapp\bld \ --cxx_include_directory C:\Green\scxx -IC:\Green\scxx \ -IC:\Green\68000\include -IC:\Green\ansi \ '; foreach (@input) { print "$1\n" while /\B(-I\S+)/g; } ___OUTPUT___ -IE:\david\nbssbts\btsc\bld -IE:\david\nbsscis\dcsapp\bld -IC:\Green\scxx -IC:\Green\68000\include -IC:\Green\ansi
Update --
To handle embedded spaces use a zero-width lookahead.
use strict; $_ = ' -IE:\david\nbssbts\btsc\bld -IE:\david\nbsscis\dcsapp\bld \ --cxx_include_directory C:\Green\scxx -IC:\Green\scxx \ -IC:\Green\68000\include -IC:\Green\ansi \ -ID:\Path with spaces\include \ '; s/\\\n//g; print "$1\n" while /(-I.+?(?= -I| --c|$))/g; __OUTPUT__ -IE:\david\nbssbts\btsc\bld -IE:\david\nbsscis\dcsapp\bld -IC:\Green\scxx -IC:\Green\68000\include -IC:\Green\ansi -ID:\Path with spaces\include
--
flounder
In reply to Re: Re: Transforming only parts of input
by flounder99
in thread Transforming only parts of input
by amoura
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |