On Fri, 2007-02-09 at 15:16 +, Edward Kay wrote:
> > > As Rob suggested, why not just use two checks? e.g.
> > >
> > > if ( (strlen($input) == 4) && (strpos($input, '8') !== FALSE ) ) {
> > > // OK
> > > } else {
> > > // Not OK
> > > }
> > >
> > > Not only is this logic much easier to unde
[EMAIL PROTECTED] wrote:
> Hi,
>
> I was not having PHP on the machine I am reading this email for the
> moment. But I tried to use it together with egrep, but it didn't work.
> Maybe egrep is using different syntax for these lookaheads, but with
> other tests it has been working same as for preg_
Hi,
I was not having PHP on the machine I am reading this email for the
moment. But I tried to use it together with egrep, but it didn't work.
Maybe egrep is using different syntax for these lookaheads, but with
other tests it has been working same as for preg_match in PHP. As you
see the
PS: I think you can remove the last .*, leaving the assertion like this:
(?=.*8), and it will still work fine and probably faster (which dosen't
matter under these conditions). But I haven't tried that one (and have
already erased the test file I did to check the regular expression).
2007/2/9, Ma
If you want to do it in one regular expression, without listing each case,
you can use a lookahead assertion:
/^(?=.*8.*)[0-9]{4}$/
The assertion (?=.*8.*) checks that the following matches the expression
contained (.*8.*) which fails if there is not an 8.
2007/2/9, Peter Lauri <[EMAIL PROTECTE
> > As Rob suggested, why not just use two checks? e.g.
> >
> > if ( (strlen($input) == 4) && (strpos($input, '8') !== FALSE ) ) {
> > // OK
> > } else {
> > // Not OK
> > }
> >
> > Not only is this logic much easier to understand than a regexp
> - important
> > when someone else has to ma
On Fri, 2007-02-09 at 12:56 +, Edward Kay wrote:
> > [snip]
> >
> > Why not use two checks? One that checks for 4 digits, the other checks
> > for existence of 8 anywhere in the string?
> >
> > Cheers,
> > Rob.
> > [/snip]
> >
> > Of course that is a possibility. But I wonder if there is a way
# [EMAIL PROTECTED] / 2007-02-09 12:44:40 +:
> Roman Neuhauser wrote:
> >This shouldn't do too much backtracking, try it out:
> >
> >"*8*" => /^(?:\d*8\d*){4}$/
> >
> >
> The {4} in there repeats the subpattern 4 times, rather than limiting it
> to 4 characters.
OMG. Sorry, haven't got eno
> [snip]
>
> Why not use two checks? One that checks for 4 digits, the other checks
> for existence of 8 anywhere in the string?
>
> Cheers,
> Rob.
> [/snip]
>
> Of course that is a possibility. But I wonder if there is a way to do it
> with ONE expression. So there are no AND operator in Regular E
Roman Neuhauser wrote:
This shouldn't do too much backtracking, try it out:
"*8*" => /^(?:\d*8\d*){4}$/
The {4} in there repeats the subpattern 4 times, rather than limiting it
to 4 characters.
I really can't think of an elegant to do what you ask with regex - why
limit yourself to regex a
: Friday, February 09, 2007 1:36 PM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] OT - Regular Expression
# [EMAIL PROTECTED] / 2007-02-09 14:13:27 +0200:
> I want to match a four digit number. I allow user to enter with * syntax.
So
> 8* would match anything that starts with
[snip]
Why not use two checks? One that checks for 4 digits, the other checks
for existence of 8 anywhere in the string?
Cheers,
Rob.
[/snip]
Of course that is a possibility. But I wonder if there is a way to do it
with ONE expression. So there are no AND operator in Regular Expressions
then I a
# [EMAIL PROTECTED] / 2007-02-09 14:13:27 +0200:
> I want to match a four digit number. I allow user to enter with * syntax. So
> 8* would match anything that starts with 8 and is 4 digit long so:
>
> /^8[0-9]{3}$/
>
> That was easy. Ok then my other case was: *8, so anything that ends with 8
>
On Fri, 2007-02-09 at 14:13 +0200, Peter Lauri wrote:
> Best group member,
>
>
>
> I want to match a four digit number. I allow user to enter with * syntax. So
> 8* would match anything that starts with 8 and is 4 digit long so:
>
>
>
> /^8[0-9]{3}$/
>
>
>
> That was easy. Ok then my ot
Best group member,
I want to match a four digit number. I allow user to enter with * syntax. So
8* would match anything that starts with 8 and is 4 digit long so:
/^8[0-9]{3}$/
That was easy. Ok then my other case was: *8, so anything that ends with 8
/^[0-9]{3}8$/
Ok, now the t
Thanks!
On 4/3/2001 4:41 PM this was written:
> On Tuesday 03 April 2001 21:59, you wrote:
>
>> I would like to find all processes by a given user on a linux box and
>> kill them. I know this much:
>>
>> ps -u username
>>
>> Now, do I then pipe that to grep somehow and get just the PID's?
>
On Tuesday 03 April 2001 22:41, you wrote:
> (1) look up system / backtick operator / ... to get the output of the
> grep call as array, one line per entry
"... output of the ps call" of course
--
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)
CPU not found. retry, abort, ignore?
On Tuesday 03 April 2001 21:59, you wrote:
> I would like to find all processes by a given user on a linux box and
> kill them. I know this much:
>
> ps -u username
>
> Now, do I then pipe that to grep somehow and get just the PID's?
(1) look up system / backtick operator / ... to get the outpu
I know this is off-topic but what I'm using it for will be in a PHP script!
All you who are grep-masters I have a question.
I would like to find all processes by a given user on a linux box and kill
them. I know this much:
ps -u username
Now, do I then pipe that to grep somehow and get just
19 matches
Mail list logo