THRAK has asked for the wisdom of the Perl Monks concerning the following question:
Changing \s+ to \s* obviously makes it match the BOL, but it also makes it match the non-whitespace also.#!/usr/bin/perl -w use strict; use diagnostics; my $line = 'some_for($var)'; #don't match $line = ' for($var)'; #match $line = 'for($var)'; #match if ($line =~ /\s+(for\()/gi) { print 'match'; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: RegEx Beginning of line or whitespace match
by saintmike (Vicar) on Feb 11, 2005 at 21:37 UTC | |
by THRAK (Monk) on Feb 11, 2005 at 21:46 UTC | |
by CountZero (Bishop) on Feb 11, 2005 at 22:50 UTC | |
|
Re: RegEx Beginning of line or whitespace match
by eieio (Pilgrim) on Feb 11, 2005 at 21:33 UTC | |
|
Re: RegEx Beginning of line or whitespace match
by gaal (Parson) on Feb 11, 2005 at 21:35 UTC | |
|
Re: RegEx Beginning of line or whitespace match
by Frantz (Monk) on Feb 11, 2005 at 21:33 UTC | |
by ZlR (Chaplain) on Feb 12, 2005 at 17:22 UTC | |
|
Re: RegEx Beginning of line or whitespace match
by holli (Abbot) on Feb 11, 2005 at 21:38 UTC | |
|
Re: RegEx Beginning of line or whitespace match
by Anonymous Monk on Feb 12, 2005 at 15:04 UTC | |
|
Re: RegEx Beginning of line or whitespace match
by gube (Parson) on Feb 12, 2005 at 15:05 UTC |