|
Posted by Juliette on 08/23/06 07:14
FFMG wrote:
> Hi,
>
> If I have a string:
> $s = "sometext more_text hello1hello2";
>
> And I want to look for the text 'hello', I do the following regex
> search
> /hello([0-9]*)/is
> And I get the expected value of '1', (the first hello)
>
> But if I do
> /.*hello([0-9]*)/is
> I get the next 'hello', ('2').
>
> But, because I want find the first 'hello' _after_ 'sometext', I want,
> (need?), to do
>
> /sometext.*hello([0-9]*)/is
>
> But that returns the second 'hello' not the first one.
>
> What could I be doing wrong?
>
> Thanks
>
> FFMG
>
You are using the . which is a 'catch-all' and is greedy (i.e. will
'eat' as much text as it possibly can).
Navigation:
[Reply to this message]
|