RE: [PHP] Regex Problem

2008-12-18 Thread Boyd, Todd M.
 -Original Message-
 From: MikeP [mailto:mpel...@princeton.edu]
 Sent: Thursday, December 18, 2008 8:43 AM
 To: php-general@lists.php.net
 Subject: [PHP] Regex Problem
 
 Hello,
 I have  a quirky behavior I'm trying to resolve.
 I have a REGEX that will find a function definition in a php file:
 .function InsertQuery($table,$fields,$values).
 the REGEX is:
 $regex='/function [a-z]* *([$a-zA-Z]*)/';
 the problem is that:
 1. a slash is automattically put in front of the $. This is good but I
 dont
 know how it gets there.
 2.a slash is NOT put in front of the parenthesis. Thats bad
 3. If I try to escape the parenthesis with a \ , I get \\.
 Help

Mike,

Certain characters are considered special in RegEx. The $ means end
of the line, so it must be escaped to avoid confusing its meaning. I
was not sure it had to be escaped within a character set [], but that
may very well be the case. Try this:

$regex = '/function\s+[-_a-z0-9]+\s*\((\s*\$?[-_a-z0-9]+\s*,?)*\s*\)/i';

The word function is followed by 1 or more spaces (or tabs). The
function name [-_a-z0-9] can be a combination of alpha-numeric
characters, underscore, and dash. Then, there is optional whitespace
between the name of the function and its parameters. The opening
parenthesis ( for parameters has been escaped (as has the closing
parenthesis). Then, in a repeatable capture group, the parameters can be
grabbed: Indefinite whitespace, an optional $ (because maybe you're not
using a variable, eh?), one or more alpha-numeric, underscore, or dash
characters, followed by indefinite whitespace and an optional comma (if
there are more arguments). After any number of instances of the capture
group, the regex continues by looking for indefinite whitespace followed
by the closing parenthesis for the function text. The i switch at the
end simply means that this regex pattern will be treated as
case-insensitive ('APPLE' == 'apple').

If you're not worried about actually splitting up the function
parameters into capture groups, then you can just use a look-ahead to
ensure that you grab everything up till the LAST parenthesis on the
line.

$regex = '/function\s+[-_a-z0-9]+\s*\(.*?\)(?=.*\)[^)]*)/i';

That one probably needs to be tweaked a bit in order to actually grab
the last parenthesis (instead of just checking for its existence). If
you're willing to trust the text you'll be searching through, you can
probably avoid that last parenthesis rule altogether, and make a lazy
regex:

$regex = '/function\s+[-_a-z0-9]+\s*\(.*?/i';

Once you get to the opening parenthesis for the function parameters,
that last regex assumes that the rest of the line will also include that
function declaration, and just grabs everything left. If you are using a
regex setup to where the dot marker can also consume newline or carriage
return characters, just throw a $ at the end of the regex (before the
flags part /i) in order to tell it just to grab characters until it
reaches the end of the line:

$regex = '/function\s+[-_a-z0-9]+\s*\(.*?$/i';

These are all untested, but hopefully I've given you a nudge in the
right direction. If you are still getting strange behavior out of your
PCRE engine, then perhaps you have a different version installed than
what I'm used to--all of the above should work (perhaps with some very
minor changes) in PHP.

HTH,


// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Regex Problem

2008-12-18 Thread MikeP

Boyd, Todd M. tmbo...@ccis.edu wrote in message 
news:33bde0b2c17eef46acbe00537cf2a190037b7...@exchcluster.ccis.edu...
 -Original Message-
 From: MikeP [mailto:mpel...@princeton.edu]
 Sent: Thursday, December 18, 2008 8:43 AM
 To: php-general@lists.php.net
 Subject: [PHP] Regex Problem

 Hello,
 I have  a quirky behavior I'm trying to resolve.
 I have a REGEX that will find a function definition in a php file:
 .function InsertQuery($table,$fields,$values).
 the REGEX is:
 $regex='/function [a-z]* *([$a-zA-Z]*)/';
 the problem is that:
 1. a slash is automattically put in front of the $. This is good but I
 dont
 know how it gets there.
 2.a slash is NOT put in front of the parenthesis. Thats bad
 3. If I try to escape the parenthesis with a \ , I get \\.
 Help

Mike,

Certain characters are considered special in RegEx. The $ means end
of the line, so it must be escaped to avoid confusing its meaning. I
was not sure it had to be escaped within a character set [], but that
may very well be the case. Try this:

$regex = '/function\s+[-_a-z0-9]+\s*\((\s*\$?[-_a-z0-9]+\s*,?)*\s*\)/i';

The word function is followed by 1 or more spaces (or tabs). The
function name [-_a-z0-9] can be a combination of alpha-numeric
characters, underscore, and dash. Then, there is optional whitespace
between the name of the function and its parameters. The opening
parenthesis ( for parameters has been escaped (as has the closing
parenthesis). Then, in a repeatable capture group, the parameters can be
grabbed: Indefinite whitespace, an optional $ (because maybe you're not
using a variable, eh?), one or more alpha-numeric, underscore, or dash
characters, followed by indefinite whitespace and an optional comma (if
there are more arguments). After any number of instances of the capture
group, the regex continues by looking for indefinite whitespace followed
by the closing parenthesis for the function text. The i switch at the
end simply means that this regex pattern will be treated as
case-insensitive ('APPLE' == 'apple').

If you're not worried about actually splitting up the function
parameters into capture groups, then you can just use a look-ahead to
ensure that you grab everything up till the LAST parenthesis on the
line.

$regex = '/function\s+[-_a-z0-9]+\s*\(.*?\)(?=.*\)[^)]*)/i';

That one probably needs to be tweaked a bit in order to actually grab
the last parenthesis (instead of just checking for its existence). If
you're willing to trust the text you'll be searching through, you can
probably avoid that last parenthesis rule altogether, and make a lazy
regex:

$regex = '/function\s+[-_a-z0-9]+\s*\(.*?/i';

Once you get to the opening parenthesis for the function parameters,
that last regex assumes that the rest of the line will also include that
function declaration, and just grabs everything left. If you are using a
regex setup to where the dot marker can also consume newline or carriage
return characters, just throw a $ at the end of the regex (before the
flags part /i) in order to tell it just to grab characters until it
reaches the end of the line:

$regex = '/function\s+[-_a-z0-9]+\s*\(.*?$/i';

These are all untested, but hopefully I've given you a nudge in the
right direction. If you are still getting strange behavior out of your
PCRE engine, then perhaps you have a different version installed than
what I'm used to--all of the above should work (perhaps with some very
minor changes) in PHP.

HTH,


// Todd

GOT IT!!

Thanks. 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] regex problem

2006-06-01 Thread Dave Goodchild

On 01/06/06, Merlin [EMAIL PROTECTED] wrote:


Hi there,

I do work on following regex:
^(.*)_a[0-9](.*).htm$

This should be valid for test_a9393.htm, but not for 9393.htm as
ther is no leading _a infront of the number.

Unfortunatelly this also works for the 9393.htm file. Can somebody give
me a hint why the regex also is true for text that does not start with
_a infront of the number?

Thank you for any help,

Merlin



Try this:

^(.*)(_a{1})(\d+).htm$

in your regex you are looking for any instance of _, a  OR a sequence of
numbers.

I think this will search for  zero or more characters, one instance of _a,
then one or more numbers, then .htm.




--
http://www.web-buddha.co.uk

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!


Re: [PHP] regex problem

2006-06-01 Thread Merlin

Dave Goodchild schrieb:

On 01/06/06, Merlin [EMAIL PROTECTED] wrote:


Hi there,

I do work on following regex:
^(.*)_a[0-9](.*).htm$

This should be valid for test_a9393.htm, but not for 9393.htm as
ther is no leading _a infront of the number.

Unfortunatelly this also works for the 9393.htm file. Can somebody give
me a hint why the regex also is true for text that does not start with
_a infront of the number?

Thank you for any help,

Merlin



Try this:

^(.*)(_a{1})(\d+).htm$

in your regex you are looking for any instance of _, a  OR a sequence of
numbers.

I think this will search for  zero or more characters, one instance of _a,
then one or more numbers, then .htm.





Hi,

unfortunatelly it does not work. But you are right my regex: 
^(.*)_a[0-9](.*).htm$ seems to make an OR with _a OR numbers

, but I would like to have an AND.

Any other ideas?

Merlin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] regex problem

2006-06-01 Thread Dan Parry
[snip]
Hi there,

I do work on following regex:
^(.*)_a[0-9](.*).htm$

This should be valid for test_a9393.htm, but not for 9393.htm as 
ther is no leading _a infront of the number.

Unfortunatelly this also works for the 9393.htm file. Can somebody give 
me a hint why the regex also is true for text that does not start with 
_a infront of the number?

Thank you for any help,

Merlin
[/snip]

How about this:

(\w)+(_a){1}(\w)+\.htm$

Worked for me :)

HTH

Dan
-- 
Dan Parry
Senior Developer
Virtua Webtech Ltd
http://www.virtuawebtech.co.uk

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.8.0/352 - Release Date: 30/05/2006
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] regex problem

2006-06-01 Thread Robin Vickery

On 01/06/06, Merlin [EMAIL PROTECTED] wrote:

Hi there,

I do work on following regex:
^(.*)_a[0-9](.*).htm$

This should be valid for test_a9393.htm, but not for 9393.htm as
ther is no leading _a infront of the number.

Unfortunatelly this also works for the 9393.htm file. Can somebody give
me a hint why the regex also is true for text that does not start with
_a infront of the number?



It won't match something without an _a in it. So there's something
you're not mentioning.

?php
$test = array('test_a9393.htm','a9393.htm');

foreach ($test as $t) {
 print preg_match('/^(.*)_a[0-9](.*).htm$/', $t) ?
   '$t' matches.\n :
   '$t' does not match.\n;
}
?

'test_a9393.htm' matches.
'a9393.htm' does not match.

-robin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] regex problem

2006-06-01 Thread Merlin

Robin Vickery schrieb:

On 01/06/06, Merlin [EMAIL PROTECTED] wrote:

Hi there,

I do work on following regex:
^(.*)_a[0-9](.*).htm$

This should be valid for test_a9393.htm, but not for 9393.htm as
ther is no leading _a infront of the number.

Unfortunatelly this also works for the 9393.htm file. Can somebody give
me a hint why the regex also is true for text that does not start with
_a infront of the number?



It won't match something without an _a in it. So there's something
you're not mentioning.

?php
$test = array('test_a9393.htm','a9393.htm');

foreach ($test as $t) {
 print preg_match('/^(.*)_a[0-9](.*).htm$/', $t) ?
   '$t' matches.\n :
   '$t' does not match.\n;
}
?

'test_a9393.htm' matches.
'a9393.htm' does not match.

-robin


Thank you robin! That saved my ass :-) Actually my regex was quit fine, 
the problem was that there was a search function searching for 
is_numeric that was redirecting to another page *lol*


Best regards, Merlin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] regex problem

2006-06-01 Thread John Nichel

Merlin wrote:

Hi there,

I do work on following regex:
^(.*)_a[0-9](.*).htm$

This should be valid for test_a9393.htm, but not for 9393.htm as 
ther is no leading _a infront of the number.


Unfortunatelly this also works for the 9393.htm file. Can somebody give 
me a hint why the regex also is true for text that does not start with 
_a infront of the number?


Thank you for any help,

Merlin



Escape the period before htm.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] regex problem

2006-06-01 Thread Richard Lynch
On Thu, June 1, 2006 4:56 am, Merlin wrote:
 ^(.*)_a[0-9](.*).htm$

Don't know what it will help, but you need \\.htm in PHP to get \.htm
in PCRE to escape the . in the extension.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] regex problem

2004-07-01 Thread Justin Patrin
On Thu, 1 Jul 2004 16:41:50 -0500, Josh Close [EMAIL PROTECTED] wrote:
 
 I'm trying to get a simple regex to work. Here is the test script I have.
 
 #!/usr/bin/php -q
 ?
 
 $string = hello\nworld\n;
 $string = preg_replace(/[^\r]\n/i,\r\n,$string);

$string = preg_replace(/([^\r])\n/i,\\1\r\n,$string);

You could also use forward look-aheads, but I don't remember how to do
that right now.

 $string = addcslashes($string, \r\n);
 
 print $string;
 
 ?
 
 This outputs
 
 hell\r\nworl\r\n
 
 so it's removing the char before the \n also.
 
 I just want it to replace a lone \n with \r\n
 
 -Josh
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 !DSPAM:40e48327189276451316304!
 
 


-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] regex problem

2004-07-01 Thread Josh Close
Why is it taking the char before the [^\r] also?

-Josh

On Thu, 1 Jul 2004 15:17:04 -0700, Justin Patrin [EMAIL PROTECTED] wrote:
 
 On Thu, 1 Jul 2004 16:41:50 -0500, Josh Close [EMAIL PROTECTED] wrote:
 
  I'm trying to get a simple regex to work. Here is the test script I have.
 
  #!/usr/bin/php -q
  ?
 
  $string = hello\nworld\n;
  $string = preg_replace(/[^\r]\n/i,\r\n,$string);
 
 $string = preg_replace(/([^\r])\n/i,\\1\r\n,$string);
 
 You could also use forward look-aheads, but I don't remember how to do
 that right now.
 
  $string = addcslashes($string, \r\n);
 
  print $string;
 
  ?
 
  This outputs
 
  hell\r\nworl\r\n
 
  so it's removing the char before the \n also.
 
  I just want it to replace a lone \n with \r\n
 
  -Josh
  
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
  !DSPAM:40e48327189276451316304!
 
 
 
 
 --
 DB_DataObject_FormBuilder - The database at your fingertips
 http://pear.php.net/package/DB_DataObject_FormBuilder
 
 paperCrane --Justin Patrin--


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] regex problem

2004-07-01 Thread Curt Zirzow
* Thus wrote Justin Patrin:
 On Thu, 1 Jul 2004 16:41:50 -0500, Josh Close [EMAIL PROTECTED] wrote:
  
  I'm trying to get a simple regex to work. Here is the test script I have.
  
  #!/usr/bin/php -q
  ?
  
  $string = hello\nworld\n;
  $string = preg_replace(/[^\r]\n/i,\r\n,$string);
 
 $string = preg_replace(/([^\r])\n/i,\\1\r\n,$string);
 
 You could also use forward look-aheads, but I don't remember how to do
 that right now.

actually look-behind:
  preg_replace(/(?!\r)\n/, \r\n, $string);

Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] regex problem

2003-08-15 Thread Ford, Mike [LSS]
On 15 August 2003 12:02, Merlin wrote:

 Hi there,
 
 I have a regex problem.
 
 Basicly I do not want to match:
 
 /dir/test/contact.html
 
 But I do want to match:
 /test/contact.html
 
 I tryed this one:
 ^[!dir]/(.*)/contact(.*).html$

Well, that's not going to work because the construct [!dir] means match any single 
character that is ! or d or i or r.  Even if you use the correct negation character, 
to give [^dir], that's still not going to work as it means match any ONE character 
which is neither d nor i nor r.

I *think* what you want here is what's called a lookahead assertion, but I've never 
tried to use one of those so I'm not even going to attempt a suggestion; however, they 
are documented in the PHP manual at 
http://www.php.net/pcre.pattern.syntax#regexp.reference.assertions, so a good peruse 
through that section may set you on the way.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] regex problem

2003-06-01 Thread Jim Lucas
Are you wanting the $_POST['nums1'] to have only numbers, -, ., #, : 

Is this what you are trying to match.  if so, try this.

if ( preg_match(/[^0-9\#\:\.\-]/, $_POST['nums1']) ) {
  throw error()
}

This will match anything that is not a number or one of the other special
chars that are in the pattern to be matched.

Therefor, if it does find anything that is not in the pattern to be matched
it will return true and then it will enter the if statement instead of
skipping over it.

Jim Lucas
- Original Message -
From: Daniel J. Rychlik [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, May 31, 2003 11:46 AM
Subject: [PHP] regex problem


Hello,,

I have a preg_match issue matching numbers.  I am currently using

!preg_match ('/([0-9\-\.\#:])/', $_POST['nums1']
throw error[]

This fails if you use something like ' asdf ' but if you use ' asdf789 ' it
passes false and does not throw an error.
This is not the obvious solution  I know its a problem in my regular
expression.  Should I ONLY be using

' /([0-9])/ ' ,  ?

Thanks in advance.
Daniel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] regex problem

2003-06-01 Thread Daniel J. Rychlik
If I wanted to remove script/script tags from my form as well as html
tags, would I use a preg_match function or is their another simple funtion
that does this ?

-Dan

- Original Message - 
From: Jim Lucas [EMAIL PROTECTED]
To: Daniel J. Rychlik [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Saturday, May 31, 2003 6:04 PM
Subject: Re: [PHP] regex problem


 Are you wanting the $_POST['nums1'] to have only numbers, -, ., #, : 

 Is this what you are trying to match.  if so, try this.

 if ( preg_match(/[^0-9\#\:\.\-]/, $_POST['nums1']) ) {
   throw error()
 }

 This will match anything that is not a number or one of the other special
 chars that are in the pattern to be matched.

 Therefor, if it does find anything that is not in the pattern to be
matched
 it will return true and then it will enter the if statement instead of
 skipping over it.

 Jim Lucas
 - Original Message -
 From: Daniel J. Rychlik [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Saturday, May 31, 2003 11:46 AM
 Subject: [PHP] regex problem


 Hello,,

 I have a preg_match issue matching numbers.  I am currently using

 !preg_match ('/([0-9\-\.\#:])/', $_POST['nums1']
 throw error[]

 This fails if you use something like ' asdf ' but if you use ' asdf789 '
it
 passes false and does not throw an error.
 This is not the obvious solution  I know its a problem in my regular
 expression.  Should I ONLY be using

 ' /([0-9])/ ' ,  ?

 Thanks in advance.
 Daniel


 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] regex problem

2003-03-16 Thread John W. Holmes
 suppose there's a string
 $string=I like my(hot) coffee with sugar and (milk)(PHP);
 
 I would like to get an output of all possible combinations of the
sentence
 with the words between brackets:
 eg.
 I like my hot coffee with sugar and
 I like my hot coffee with sugar and milk
 I like my hot coffee with sugar and milk php
 I like my coffee with sugar and
 I like my coffee with sugar and milk php
 etc.etc.
 
 The number of the words between brackets can differ and they can occur
 everywhere. The most important is that all combinations are returned
but
 the
 sentence (not between brackets) should be there.

Here's a solution. :) Hope it helps. You could adapt it to not use the
placeholders if each word in parenthesis is unique. 

?

$text = I like my (hot) coffee with sugar and (milk)(PHP);

//match words between parenthesis
preg_match_all(/\((.*)\)/U,$text,$matches);

//replace words with placeholder
//#x# where 'x' is incremented
//for each placeholder
$a=0;
$text2 = preg_replace(/\((.*)\)/Ue,'sprintf(#%d#,$a++)',$text);

//determine how many words were matched
//and what decimal number equals a binary 
//number of all ones and a length equal to
//the number of matches
$num_matches = count($matches[0]);
$dec = bindec(str_repeat(1,$num_matches));

//Original text
echo $text . hr;

for($x=0;$x=$dec;$x++)
{
$text3 = $text2;
$cpy = $x;
//loop equal to the number of matched words
for($y=0;$y$num_matches;$y++)
{
//if least significant bit is one then
//replace placeholder with word from $matches
//otherwise an empty string
$replace = ($cpy  1) ? $matches[1][$y] : '';
$text3 = str_replace(#$y#,$replace,$text3);
//shift bits in $cpy one to the right
$cpy = $cpy  1;
}
echo $text3 . br;
}

?

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] regex problem

2003-03-13 Thread CPT John W. Holmes
 suppose there's a string
 $string=I like my(hot) coffee with sugar and (milk)(PHP);

 I would like to get an output of all possible combinations of the sentence
 with the words between brackets:
 eg.
 I like my hot coffee with sugar and
 I like my hot coffee with sugar and milk
 I like my hot coffee with sugar and milk php
 I like my coffee with sugar and
 I like my coffee with sugar and milk php
 etc.etc.

 The number of the words between brackets can differ and they can occur
 everywhere. The most important is that all combinations are returned but
the
 sentence (not between brackets) should be there.

 I got something like:
 preg_match(/\((.*?)\)(.*)\((.*?)\)+/,$string,$regresult);


 but the \((.*?)\) part that matches the things between brackets is fixed.
 There can be a variable number of these words between brackets. How do i
do
 this? And how could i easily get the combinations? Can i do it all just
with
 preg_match or should i construct the combinations with some additional
code?

I'm just thinking outloud here. I'll see if I can get some time to write
actual code later.

1. match all words between paranthesis and place into $match.

2. replace words with placeholders, something like %1%, %2%, etc...

3. count how many words you matched (assume 3 for this example).

4. Now, i'm thinking of making all of your sentences sort of like a binary
number. Since we have three matches, we have a 3 digit binary number. To
diplay all of the words in all of the combinations, we have to count from
000 to 111 where 0 is the word not showing up and one is it showing up.

000 = I like my coffee with sugar and
001 = I like my coffee with sugar and PHP
010 = I like my coffee with sugar and milk

101 = I like myhot coffee with sugar and PHP
etc...

5. So if you have $z matches, you'll want to loop from $x = 0 until
$x=bindec(str_repeat(1,$z))

6 make a copy of $x... $copy = $x.

7 While ($copy != 0)

8. if($copy  1), then replace placeholder %$x% with $match[$x]

9. Shift the bits in $copy one to the right. ($copy1) and go back to #7.

10. Once $copy is zero, replace any placeholders left with an empty string
and display the sentence.

11. Go back to #5 and increment x (next for loop).

I hope that's confusing enough... or not confusing.. either way. I can write
some actual code if you want, but it'll be later today after work. Let me
know.

---John Holmes...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Regex problem

2001-10-25 Thread Kodrik

 My solution:
 ereg(^[:space:]*\*,$variable)

Try
ereg(^[:space:]\**$,$variable)
or
ereg(^[ ]*\**$,$variable)
or
ereg(^[[:space:]]*\**$,$variable)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]