For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > June 2005 > Regex needed









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Regex needed
Robert

2005-06-09, 8:55 pm

I have a log file where the last portion of the events look like:

Printer driver: (Lexmark T520)

Where the portion in parens will change but it will always look like that.

Robert


John Doe

2005-06-09, 8:55 pm

Robert am Donnerstag, 9. Juni 2005 14.51:
> I have a log file where the last portion of the events look like:
>
> Printer driver: (Lexmark T520)
>
> Where the portion in parens will change but it will always look like that.


If I guess right that you want to extract the portion in (), what about

perldoc perlrequick
perldoc perlretut
perldoc perlre

and

my $line = 'Text at beginning of line Printer driver: (Lexmark T520)';
my ($printer)=$line=~/\((.*)\)\s*$/o;
print 'Portion in (): ', $printer;



greetings
joe
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com