[EMAIL PROTECTED] wrote:
> Hi
> 
> I am trying to regex a make output line (g++) and don't get it together.
> What I want is:
> 
> All lines where the -c option does not occure, neither before nor after the 
> -o option and then extract the portion after the -o option.
> 
> $regexApplication = '(?<![ \t]-c[ \t])-o[ 
> \t]+((/?([\w\.]+/)*)?([\w]+(\.[\w]+)?))[ \t]+(?!.*[ \t]-c[ \t])';
> 
> $refStrAppl = \$1;
> 
> elsif( $inputLine =~ m/$regexApplication/ )
> {
>   push( @applications, $$refStrAppl );
> }
> 
> How do I build a regex that checks for inexitstance of a certain pattern, in 
> my case [ \t]-c[ \t] and existance of another pattern, my case -o[ 
> \t]+((/?([\w\.]+/)*)?([\w]+(\.[\w]+)?))[ \t]+    ? (last q-mark is not regex) 
> 
> Or do I have to split it? I am close to do it that way. Not nice, but simpler.
> 
> Appreciate any help

If you mean by 'split it' that you could do separate tests in separate
statements then I think there's nothing 'not nice' about it. If you're
determined to use regexes then I would say that was the way to go: first
check whether the -c option is present, and if not look for the -o
option and value.

You should also consider using the Getopt::Std standard module (or
Getopt::Long if that isn't comprehensive enough for you).

HTH,

Rob

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to