RE: [PHP] Strings and regular expression?

2003-02-07 Thread John W. Holmes
> > Very true, I agree. For your solution, though, wouldn't it correctly > match a > > string such as '2,3,11,12' even though there is no entry that's just > one? > > Ok, why not something like this.. > There is almost always a better solution than regex > > > $string = '98,244,9,243,2,6,36,3,1

Re: [PHP] Strings and regular expression?

2003-02-07 Thread Kevin Waterson
This one time, at band camp, "1LT John W. Holmes" <[EMAIL PROTECTED]> wrote: > > Very true, I agree. For your solution, though, wouldn't it correctly match a > string such as '2,3,11,12' even though there is no entry that's just one? Ok, why not something like this.. There is almost always a bet

Re: [PHP] Strings and regular expression?

2003-02-07 Thread 1LT John W. Holmes
> > > $a1="1,8,98,244,9,243,2,6,36,3,111,"; > > > > > > $a2="8,98,244,9,243,2,1,6,36,3,111,"; > > > > > > How can I exactly match "1," in both strings using one regular expression? > > > (first "1" is the first element and second time in a random position)? > > > > if(preg_match('/(^|,)1(,|$)/',$st

Re: [PHP] Strings and regular expression?

2003-02-07 Thread Kevin Waterson
This one time, at band camp, "1LT John W. Holmes" <[EMAIL PROTECTED]> wrote: > > $a1="1,8,98,244,9,243,2,6,36,3,111,"; > > > > $a2="8,98,244,9,243,2,1,6,36,3,111,"; > > > > How can I exactly match "1," in both strings using one regular expression? > > (first "1" is the first element and second tim

Re: [PHP] Strings and regular expression?

2003-02-07 Thread 1LT John W. Holmes
> $a1="1,8,98,244,9,243,2,6,36,3,111,"; > > $a2="8,98,244,9,243,2,1,6,36,3,111,"; > > How can I exactly match "1," in both strings using one regular expression? > (first "1" is the first element and second time in a random position)? if(preg_match('/(^|,)1(,|$)/',$str)) { echo "one is found"; } -