Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Open Source > Perl
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Perl section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 31st, 2009, 11:27 PM
Authorized User
 
Join Date: Nov 2007
Posts: 33
Thanks: 2
Thanked 0 Times in 0 Posts
Question Regular Expression Error

Hi,

I'm trying to split a line if it's match with my pattern.
I would like to get [user:myuser][filename:test.txt][status:pending][here something else] from a line.

eg. $line is
Code:
[localhost 2009/09/01 12:34:02] ME INFO: [user:myuser][filename:test.txt][status:pending][here something else]
Code:
if($line =~ /.*(\[.*\]{3,}).*/)
{
   print $line;
}
My regex doesn't match with my line.
Can someone tell me what's wrong with my regular expression.

Thanks
 
Old September 6th, 2009, 01:05 PM
Authorized User
 
Join Date: Aug 2009
Posts: 23
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Of course it wouldn't match - you don't have ']]]' in your string.

use /((?:\[.*\]){3,})/





Similar Threads
Thread Thread Starter Forum Replies Last Post
regular expression MunishBhatia ASP.NET 2.0 Professional 5 May 22nd, 2007 07:59 AM
Unknown Modifier Error - Regular Expression Beebs BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 March 20th, 2007 05:48 PM
Regular Expression Error kwilliams ASP.NET 1.0 and 1.1 Basics 3 February 16th, 2006 04:49 PM
regular expression Moharo Pro PHP 3 April 30th, 2004 04:44 AM
help in regular expression diby Beginning PHP 1 September 17th, 2003 12:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.