Re: [PHP] Re: Regex

2012-07-27 Thread David Harkness
On Fri, Jul 27, 2012 at 11:43 AM, Al n...@ridersite.org wrote:

 %[\w\d,.]%


\w will match digits so \d isn't necessary, but it will also match
underscores which isn't desired.

David


Re: [PHP] Re: Regex

2012-07-27 Thread Al



On 7/27/2012 2:56 PM, David Harkness wrote:

On Fri, Jul 27, 2012 at 11:43 AM, Al n...@ridersite.org wrote:


%[\w\d,.]%



\w will match digits so \d isn't necessary, but it will also match
underscores which isn't desired.

David


You're correct, I forgot about the darn _ and \w includes digits

So, how's about this.
%(?!_)[\w,.]%


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



Re: [PHP] Re: Regex for extracting quoted strings

2011-03-07 Thread Shawn McKenzie
On 03/05/2011 04:38 PM, Mark Kelly wrote:
 Hi.
 
 Thanks for all the replies.
 
 On Saturday 05 Mar 2011 at 22:11 Simon J Welsh wrote:
 
 On 6/03/2011, at 11:08 AM, Shawn McKenzie wrote:
 $regex = '/([^]+)/';
 
 Shawn, this regex gets me two copies of each string - one with and one 
 without 
 the double quotes - as did the one Nathan posted earlier.
  
 Also, you'll want preg_match_all rather than preg_match.
 
 Yeah, I realised that quite early on in my messing about.
 
 What I have ended up with is:
 
 $regex = '/.*?/';
 $found = preg_match_all($regex, $sentence, $phrases);
 
 This still leaves the quotes in the phrases, but at least I only get one copy 
 of each phrase. I'm just trimming the quotes afterwards.
 
 Thanks for all the advice.
 
 Mark

$sentence = 'Dave said This is it. Nope, that is the wrong colour
she replied.';

$regex = '/([^]+)/';
preg_match_all($regex, $sentence, $phrases);

print_r($phrases[1]);

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Re: Regex for extracting quoted strings

2011-03-05 Thread Simon J Welsh

On 6/03/2011, at 11:08 AM, Shawn McKenzie wrote:

 On 03/05/2011 09:26 AM, Mark Kelly wrote:
 Hi.
 
 I'm hoping someone can help me extract text between double quotes from a 
 string.
 
 $regex = 'some magic';
 $r = preg_match($regex, $sentence, $phrases);
 
 So, if 
 
 $sentence = 'Dave said This is it. Nope, that is the wrong colour she 
 replied.';
 
 I want $phrases to contain 'This is it' and 'Nope, that is the wrong colour'.
 
 Can anyone help?
 
 Cheers,
 
 Mark
 
 $regex = '/([^]+)/';
 
 -- 
 Thanks!
 -Shawn
 http://www.spidean.com

Also, you'll want preg_match_all rather than preg_match.

---
Simon Welsh
Admin of http://simon.geek.nz/

Who said Microsoft never created a bug-free program? The blue screen never, 
ever crashes!

http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e


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



Re: [PHP] Re: Regex for extracting quoted strings

2011-03-05 Thread Mark Kelly
Hi.

Thanks for all the replies.

On Saturday 05 Mar 2011 at 22:11 Simon J Welsh wrote:

 On 6/03/2011, at 11:08 AM, Shawn McKenzie wrote:
  $regex = '/([^]+)/';

Shawn, this regex gets me two copies of each string - one with and one without 
the double quotes - as did the one Nathan posted earlier.
 
 Also, you'll want preg_match_all rather than preg_match.

Yeah, I realised that quite early on in my messing about.

What I have ended up with is:

$regex = '/.*?/';
$found = preg_match_all($regex, $sentence, $phrases);

This still leaves the quotes in the phrases, but at least I only get one copy 
of each phrase. I'm just trimming the quotes afterwards.

Thanks for all the advice.

Mark

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



Re: [PHP] Re: Regex for extracting quoted strings

2011-03-05 Thread Shuo
Maybe this will help.

$regex = '/(?=)[^.]*(?=)/';
$r = preg_match_all($regex, $sentence, $phrases);


Re: [PHP] Re: Regex for telephone numbers

2010-12-31 Thread a...@ashleysheridan.co.uk
Erm, you say regex is overkill, then use one in your example!

Thanks,
Ash
http://www.ashleysheridan.co.uk

- Reply message -
From: Al n...@ridersite.org
Date: Fri, Dec 31, 2010 15:53
Subject: [PHP] Re: Regex for telephone numbers
To: php...@lists.php.net, php-general@lists.php.net



On 12/29/2010 7:12 PM, Ethan Rosenberg wrote:
 Dear List -

 Thank you for all your help in the past.

 Here is another one

 I would like to have a regex which would validate that a telephone number is
 in the format xxx-xxx-.

 Thanks.

 Ethan

 MySQL 5.1 PHP 5 Linux [Debian (sid)]


Regex is over-kill.

$phoneNum = preg_replace(%\D%, '', $phoneNum);//Remove everything except 
digits

$phoneNum = ltrim($phoneNum,'1');//Remove leading 1s

if(strlen($phoneValue) != 10)
 {
throw new Exception(Phone number must be 10 digits, without leading a 1. Check 
your entry carefull);
 }

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



Re: [PHP] Re: Regex for telephone numbers

2010-12-31 Thread Al



On 12/31/2010 11:10 AM, a...@ashleysheridan.co.uk wrote:

Erm, you say regex is overkill, then use one in your example!

Thanks,
Ash
http://www.ashleysheridan.co.uk

- Reply message -
From: Aln...@ridersite.org
Date: Fri, Dec 31, 2010 15:53
Subject: [PHP] Re: Regex for telephone numbers
To:php...@lists.php.net,php-general@lists.php.net



On 12/29/2010 7:12 PM, Ethan Rosenberg wrote:

Dear List -

Thank you for all your help in the past.

Here is another one

I would like to have a regex which would validate that a telephone number is
in the format xxx-xxx-.

Thanks.

Ethan

MySQL 5.1 PHP 5 Linux [Debian (sid)]



Regex is over-kill.

$phoneNum = preg_replace(%\D%, '', $phoneNum);//Remove everything except 
digits

$phoneNum = ltrim($phoneNum,'1');//Remove leading 1s

if(strlen($phoneValue) != 10)
  {
throw new Exception(Phone number must be 10 digits, without leading a 1. Check
your entry carefull);
  }



Save and use the resultant $phoneNum; It is all that needs to be saved and used. 
Dashes, spaces and () are superfluous. Only the 10 digits are required for his 
application.


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



Re: [PHP] Re: Regex for telephone numbers

2010-12-31 Thread Per Jessen
Al wrote:

 
 
 On 12/29/2010 7:12 PM, Ethan Rosenberg wrote:
 Dear List -

 Thank you for all your help in the past.

 Here is another one

 I would like to have a regex which would validate that a telephone
 number is in the format xxx-xxx-.

 Thanks.

 Ethan

 MySQL 5.1 PHP 5 Linux [Debian (sid)]

 
 Regex is over-kill.

You've just used one any way:

 $phoneNum = preg_replace(%\D%, '', $phoneNum);//Remove everything except 
 digits 
 
 $phoneNum = ltrim($phoneNum,'1');//Remove leading 1s
 
 if(strlen($phoneValue) != 10)
  {
 throw new Exception(Phone number must be 10 digits, without leading a
 1. Check your entry carefull);
  }

One regex and two function calls when one regex would have sufficed?


-- 
Per Jessen, Zürich (2.6°C)


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



Re: [PHP] Re: Regex Problem

2009-07-31 Thread Shawn McKenzie
Igor Escobar wrote:
 No no, i need to make an regex to match the bold areas in my string.
 Anything between single quotes or double quotes (including quotes and
 double quotes). Understand?


 Regards,
 Igor Escobar
 Systems Analyst  Interface Designer

 + http://blog.igorescobar.com
 + http://www.igorescobar.com
 + @igorescobar (twitter)

That's not going to happen without some other criteria.  There is no way
for the regex engine to guess at which sets of quotes belong inside
another set of quotes.

-Shawn

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



Re: [PHP] Re: Regex Problem

2009-07-31 Thread Shawn McKenzie
Shawn McKenzie wrote:
 Igor Escobar wrote:
 No no, i need to make an regex to match the bold areas in my string.
 Anything between single quotes or double quotes (including quotes and
 double quotes). Understand?


 Regards,
 Igor Escobar
 Systems Analyst  Interface Designer

 + http://blog.igorescobar.com
 + http://www.igorescobar.com
 + @igorescobar (twitter)

 That's not going to happen without some other criteria.  There is no way
 for the regex engine to guess at which sets of quotes belong inside
 another set of quotes.
 
 -Shawn

Especially since in one of your examples you don't even have an even
number of quotes.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Re: Regex help

2008-09-09 Thread Jason Pruim


On Sep 9, 2008, at 4:38 PM, Nathan Rixham wrote:


Jason Pruim wrote:

Hey everyone,
Not completely specific to php but I know you guys know regex's   
better then I do! :)
I am attempting to match purl.schreurprinting.com/jasonpruim112 to  
purl.schreurprinting.com/p.php?purl=jasonpruim112

Here are my current matching patterns:
   RewriteRule /(.*) /volumes/raider/webserver/ 
documents/dev/schreurprinting.com/p.php?purl=$

#   RewriteRule /(*.) /purl.schreurprinting.com/$1
#   RewriteRule /(mail.php?purl=*) / 
purl.schreurprinting.com/mail.php?purl=$1
Yes I am doing this for apache's mod_rewrite, but my question is  
much more specific to regex's at this point :)
Any ideas where I am going wrong? it seems like it should be fairly  
simple to do, but I don't know regex's at all :)

--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]


RewriteRule ^jasonpruim112$ /p.php?purl=jasonpruim112 [L]


Just tried it, and it pops up with a 404... I'll keep looking.

One other thing that I should probably add is the fact that the  
^jasonpruim112$ could have hundreds of counterparts ^bobsmith112$  
^jerrybob112$ etc... etc...


Thanks for looking though!



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]





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



Re: [PHP] Re: Regex help

2008-09-09 Thread Nathan Rixham

Jason Pruim wrote:


On Sep 9, 2008, at 4:38 PM, Nathan Rixham wrote:


Jason Pruim wrote:

Hey everyone,
Not completely specific to php but I know you guys know regex's  
better then I do! :)
I am attempting to match purl.schreurprinting.com/jasonpruim112 to 
purl.schreurprinting.com/p.php?purl=jasonpruim112

Here are my current matching patterns:
   RewriteRule /(.*) 
/volumes/raider/webserver/documents/dev/schreurprinting.com/p.php?purl=$ 


#   RewriteRule /(*.) /purl.schreurprinting.com/$1
#   RewriteRule /(mail.php?purl=*) 
/purl.schreurprinting.com/mail.php?purl=$1
Yes I am doing this for apache's mod_rewrite, but my question is much 
more specific to regex's at this point :)
Any ideas where I am going wrong? it seems like it should be fairly 
simple to do, but I don't know regex's at all :)

--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]


RewriteRule ^jasonpruim112$ /p.php?purl=jasonpruim112 [L]


Just tried it, and it pops up with a 404... I'll keep looking.

One other thing that I should probably add is the fact that the 
^jasonpruim112$ could have hundreds of counterparts ^bobsmith112$ 
^jerrybob112$ etc... etc...


Thanks for looking though!



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]




here's a typical rule; probably best to modify what works and go from 
there :)


RewriteRule ^directory/(.*)$ /newdirectory/$1 [L]

the other alternative is to let php handle it..
this is basicaly if request isn't a file or a directory route to a php 
handler [my prefered way]:


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /notfound_handler.php [L]

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



Re: [PHP] Re: Regex help

2008-09-09 Thread Per Jessen
Jason Pruim wrote:

 
 On Sep 9, 2008, at 4:38 PM, Nathan Rixham wrote:
 
 Jason Pruim wrote:
 Hey everyone,
 Not completely specific to php but I know you guys know regex's
 better then I do! :)
 I am attempting to match purl.schreurprinting.com/jasonpruim112 to
 purl.schreurprinting.com/p.php?purl=jasonpruim112
 Here are my current matching patterns:
RewriteRule /(.*) /volumes/raider/webserver/
 documents/dev/schreurprinting.com/p.php?purl=$
 #   RewriteRule /(*.) /purl.schreurprinting.com/$1
 #   RewriteRule /(mail.php?purl=*) /
 purl.schreurprinting.com/mail.php?purl=$1
 Yes I am doing this for apache's mod_rewrite, but my question is
 much more specific to regex's at this point :)
 Any ideas where I am going wrong? it seems like it should be fairly
 simple to do, but I don't know regex's at all :)
 --
 Jason Pruim
 Raoset Inc.
 Technology Manager
 MQC Specialist
 11287 James St
 Holland, MI 49424
 www.raoset.com
 [EMAIL PROTECTED]

 RewriteRule ^jasonpruim112$ /p.php?purl=jasonpruim112 [L]
 
 Just tried it, and it pops up with a 404... I'll keep looking.
 
 One other thing that I should probably add is the fact that the
 ^jasonpruim112$ could have hundreds of counterparts ^bobsmith112$
 ^jerrybob112$ etc... etc...
 

Maybe this:

RewriteCond %{REQUEST_URI} !^/p\.php
RewriteRule ^/(.+)$ /p.php?purl=$1


/Per Jessen, Zürich


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



Re: [PHP] Re: Regex help

2008-09-09 Thread Jason Pruim


On Sep 9, 2008, at 5:02 PM, Nathan Rixham wrote:


Jason Pruim wrote:

On Sep 9, 2008, at 4:38 PM, Nathan Rixham wrote:

Jason Pruim wrote:

Hey everyone,
Not completely specific to php but I know you guys know regex's   
better then I do! :)
I am attempting to match purl.schreurprinting.com/jasonpruim112  
to purl.schreurprinting.com/p.php?purl=jasonpruim112

Here are my current matching patterns:
  RewriteRule /(.*) /volumes/raider/webserver/ 
documents/dev/schreurprinting.com/p.php?purl=$

#   RewriteRule /(*.) /purl.schreurprinting.com/$1
#   RewriteRule /(mail.php?purl=*) / 
purl.schreurprinting.com/mail.php?purl=$1
Yes I am doing this for apache's mod_rewrite, but my question is  
much more specific to regex's at this point :)
Any ideas where I am going wrong? it seems like it should be  
fairly simple to do, but I don't know regex's at all :)

--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]


RewriteRule ^jasonpruim112$ /p.php?purl=jasonpruim112 [L]

Just tried it, and it pops up with a 404... I'll keep looking.
One other thing that I should probably add is the fact that the  
^jasonpruim112$ could have hundreds of counterparts  
^bobsmith112$ ^jerrybob112$ etc... etc...

Thanks for looking though!
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]

here's a typical rule; probably best to modify what works and go  
from there :)


RewriteRule ^directory/(.*)$ /newdirectory/$1 [L]

the other alternative is to let php handle it..
this is basicaly if request isn't a file or a directory route to a  
php handler [my prefered way]:


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /notfound_handler.php [L]


Interesting idea... I hadn't thought about that... Then I could just  
use a regex in php and grab everything after the domain name and pass  
it to my database to search and find the appropriate info to pull out...


I'll have to do some searching :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]





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



Re: [PHP] Re: Regex help

2008-09-09 Thread Jochem Maas

Jason Pruim schreef:


On Sep 9, 2008, at 5:02 PM, Nathan Rixham wrote:


Jason Pruim wrote:

On Sep 9, 2008, at 4:38 PM, Nathan Rixham wrote:

Jason Pruim wrote:

Hey everyone,
Not completely specific to php but I know you guys know regex's  
better then I do! :)
I am attempting to match purl.schreurprinting.com/jasonpruim112 to 
purl.schreurprinting.com/p.php?purl=jasonpruim112

Here are my current matching patterns:
  RewriteRule /(.*) 
/volumes/raider/webserver/documents/dev/schreurprinting.com/p.php?purl=$ 


#   RewriteRule /(*.) /purl.schreurprinting.com/$1
#   RewriteRule /(mail.php?purl=*) 
/purl.schreurprinting.com/mail.php?purl=$1
Yes I am doing this for apache's mod_rewrite, but my question is 
much more specific to regex's at this point :)
Any ideas where I am going wrong? it seems like it should be fairly 
simple to do, but I don't know regex's at all :)

--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]


RewriteRule ^jasonpruim112$ /p.php?purl=jasonpruim112 [L]

Just tried it, and it pops up with a 404... I'll keep looking.
One other thing that I should probably add is the fact that the 
^jasonpruim112$ could have hundreds of counterparts ^bobsmith112$ 
^jerrybob112$ etc... etc...

Thanks for looking though!
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]

here's a typical rule; probably best to modify what works and go from 
there :)


RewriteRule ^directory/(.*)$ /newdirectory/$1 [L]

the other alternative is to let php handle it..
this is basicaly if request isn't a file or a directory route to a php 
handler [my prefered way]:


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /notfound_handler.php [L]


RewriteRule . /notfound_handler.php [L,QSA]

the QSA tells apache to to automatically append any query string, saves
the hassle of having to deal with it in the regexp (assuming you might need it)

also beware that external redirects will cause POSTs to become GETs so that
the script/code in question never recieves the POST.



Interesting idea... I hadn't thought about that... Then I could just use 
a regex in php and grab everything after the domain name and pass it to 
my database to search and find the appropriate info to pull out...


your probably wanting the info in $_SERVER['REQUEST_URI'] ... which is
the complete uri before it was rewritten.

also check this func out, will probably spare you the regexp completely:

http://php.net/manual/en/function.parse-url.php



I'll have to do some searching :)


always ;-)





--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]








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



Re: [PHP] Re: Regex help

2008-09-09 Thread Jason Pruim


On Sep 9, 2008, at 12:18 PM, Jochem Maas wrote:


Jason Pruim schreef:

On Sep 9, 2008, at 5:02 PM, Nathan Rixham wrote:

Jason Pruim wrote:

On Sep 9, 2008, at 4:38 PM, Nathan Rixham wrote:

Jason Pruim wrote:

Hey everyone,
Not completely specific to php but I know you guys know  
regex's  better then I do! :)
I am attempting to match purl.schreurprinting.com/jasonpruim112  
to purl.schreurprinting.com/p.php?purl=jasonpruim112

Here are my current matching patterns:
 RewriteRule /(.*) /volumes/raider/webserver/ 
documents/dev/schreurprinting.com/p.php?purl=$

#   RewriteRule /(*.) /purl.schreurprinting.com/$1
#   RewriteRule /(mail.php?purl=*) / 
purl.schreurprinting.com/mail.php?purl=$1
Yes I am doing this for apache's mod_rewrite, but my question  
is much more specific to regex's at this point :)
Any ideas where I am going wrong? it seems like it should be  
fairly simple to do, but I don't know regex's at all :)

--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]


RewriteRule ^jasonpruim112$ /p.php?purl=jasonpruim112 [L]

Just tried it, and it pops up with a 404... I'll keep looking.
One other thing that I should probably add is the fact that the  
^jasonpruim112$ could have hundreds of counterparts  
^bobsmith112$ ^jerrybob112$ etc... etc...

Thanks for looking though!
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]

here's a typical rule; probably best to modify what works and go  
from there :)


RewriteRule ^directory/(.*)$ /newdirectory/$1 [L]

the other alternative is to let php handle it..
this is basicaly if request isn't a file or a directory route to a  
php handler [my prefered way]:


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /notfound_handler.php [L]


RewriteRule . /notfound_handler.php [L,QSA]

the QSA tells apache to to automatically append any query string,  
saves
the hassle of having to deal with it in the regexp (assuming you  
might need it)


also beware that external redirects will cause POSTs to become GETs  
so that

the script/code in question never recieves the POST.


Interesting... that may explain a problem I am having with some other  
local links in that directory...





Interesting idea... I hadn't thought about that... Then I could  
just use a regex in php and grab everything after the domain name  
and pass it to my database to search and find the appropriate info  
to pull out...


your probably wanting the info in $_SERVER['REQUEST_URI'] ... which is
the complete uri before it was rewritten.


That's actually what I started using, then I just explode that to get  
my query string to use in the database lookup.





also check this func out, will probably spare you the regexp  
completely:


http://php.net/manual/en/function.parse-url.php


Ohhh... That sounds promising... I'll have to take a look at it later.




I'll have to do some searching :)


always ;-)


The problem with the internet is there is so much out there... Trying  
to weed the crap from the food can be a long digestive process which  
ends up with MORE crap coming out... This list... It's like pepto  
bismo for my programming :P



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]





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



Re: [PHP] Re: Regex help

2008-09-09 Thread Jochem Maas

Jason Pruim schreef:


On Sep 9, 2008, at 12:18 PM, Jochem Maas wrote:



...


I'll have to do some searching :)


always ;-)


The problem with the internet is there is so much out there... Trying to 
weed the crap from the food can be a long digestive process which ends 
up with MORE crap coming out... This list... It's like pepto bismo for 
my programming :P


and there is us trying so hard to give everyone stomach ulcers :-)
must  try  harder.




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]








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



Re: [PHP] Re: regex

2008-08-13 Thread Micah Gersten
Take a look at this function, it'll make things  a little easier:
http://us3.php.net/manual/en/function.parse-str.php

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Philip Thompson wrote:
 Figured it out. Just needed to stretch my brain a lil.

 On Aug 13, 2008, at 3:07 PM, Philip Thompson wrote:

 ?php
 function blegh ($subject) {
  // I know this pattern doesn't exactly work
  $pattern = '/(.*).php\?action=([^].*)/';

 $pattern = '/(.*).php\?action=([^]+)+/';


  preg_match ($pattern, $subject, $matches);
  return $matches;
 }

 blegh ('somePage.php?action=doSomethingid=');
 ?

 Ok, the important parts that I need to obtain from this are:

 somePage
 doSomething

 How can you modify the pattern above to grab the action
 appropriately? Sorry, my regex is a lil rusty!

 Thanks in advance,
 ~Phil

 Cheers,
 ~Philip


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



RE: [PHP] Re: regex

2008-08-13 Thread Boyd, Todd M.
 -Original Message-
 From: Shawn McKenzie [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, August 13, 2008 3:31 PM
 To: php-general@lists.php.net
 Subject: [PHP] Re: regex
 
 Philip Thompson wrote:
  Figured it out. Just needed to stretch my brain a lil.
 
  On Aug 13, 2008, at 3:07 PM, Philip Thompson wrote:
 
  ?php
  function blegh ($subject) {
   // I know this pattern doesn't exactly work
   $pattern = '/(.*).php\?action=([^].*)/';
 
  $pattern = '/(.*).php\?action=([^]+)+/';
 
 
   preg_match ($pattern, $subject, $matches);
   return $matches;
  }
 
  blegh ('somePage.php?action=doSomethingid=');
  ?
 
  Ok, the important parts that I need to obtain from this are:
 
  somePage
  doSomething
 
  How can you modify the pattern above to grab the action
 appropriately?
  Sorry, my regex is a lil rusty!
 
  Thanks in advance,
  ~Phil
 
  Cheers,
  ~Philip
 
 That regex might not always work for you, (amp;) comes to mind.  You
 might want to look at parse_str() which you can use after parse_url()
 if
 needed.

I think /(.*)\.php\?action=([^]+(?()[^+]+))/ might be a step in the
right direction for RegExing the additional URL query string parameters.
I haven't tested it... but either way, I thought it was worth mentioning
that the .php part should be \.php (or [.]php), otherwise it will
match any character followed by php.


Todd Boyd
Web Programmer



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



Re: [PHP] Re: regex

2008-08-13 Thread Philip Thompson

On Aug 13, 2008, at 3:31 PM, Shawn McKenzie wrote:


Philip Thompson wrote:

Figured it out. Just needed to stretch my brain a lil.
On Aug 13, 2008, at 3:07 PM, Philip Thompson wrote:

?php
function blegh ($subject) {
// I know this pattern doesn't exactly work
$pattern = '/(.*).php\?action=([^].*)/';

$pattern = '/(.*).php\?action=([^]+)+/';

preg_match ($pattern, $subject, $matches);
return $matches;
}

blegh ('somePage.php?action=doSomethingid=');
?

Ok, the important parts that I need to obtain from this are:

somePage
doSomething

How can you modify the pattern above to grab the action  
appropriately? Sorry, my regex is a lil rusty!


Thanks in advance,
~Phil

Cheers,
~Philip


That regex might not always work for you, (amp;) comes to mind.   
You might want to look at parse_str() which you can use after  
parse_url() if needed.


-Shawn


That's a good thought. However, I am specifically sending a URL that  
has not yet been urlencoded, so I know that amp; won't be occurring.


Thanks,
~Philip


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



Re: [PHP] Re: regex

2008-08-13 Thread Philip Thompson

On Aug 13, 2008, at 4:06 PM, Boyd, Todd M. wrote:


-Original Message-
From: Shawn McKenzie [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 13, 2008 3:31 PM
To: php-general@lists.php.net
Subject: [PHP] Re: regex

Philip Thompson wrote:

Figured it out. Just needed to stretch my brain a lil.

On Aug 13, 2008, at 3:07 PM, Philip Thompson wrote:


?php
function blegh ($subject) {
// I know this pattern doesn't exactly work
$pattern = '/(.*).php\?action=([^].*)/';


$pattern = '/(.*).php\?action=([^]+)+/';



preg_match ($pattern, $subject, $matches);
return $matches;
}

blegh ('somePage.php?action=doSomethingid=');
?

Ok, the important parts that I need to obtain from this are:

somePage
doSomething

How can you modify the pattern above to grab the action

appropriately?

Sorry, my regex is a lil rusty!

Thanks in advance,
~Phil


Cheers,
~Philip


That regex might not always work for you, (amp;) comes to mind.  You
might want to look at parse_str() which you can use after parse_url()
if
needed.


I think /(.*)\.php\?action=([^]+(?()[^+]+))/ might be a step in the
right direction for RegExing the additional URL query string  
parameters.
I haven't tested it... but either way, I thought it was worth  
mentioning
that the .php part should be \.php (or [.]php), otherwise it  
will

match any character followed by php.


Todd Boyd
Web Programmer


Good call! I so passed over that one. ;)

Thanks,
~Philip


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



Re: [PHP] re regex error

2007-03-14 Thread Jim Lucas

jekillen wrote:

Hello again;
Regarding the error I  was inquiring about:

Warning: ereg() [function.ereg]: REG_ERANGE in path info_proc.php on 
line 81


I still would like to know what it means but
I solved the script problem.
I found that since  $groups is a string  that was exploded to form the 
$g_list array
it may have been struggling to try and crawl back through the whole 
string in the
middle of the for loop. But I don't know, because I don't know what 
REG_ERANGE means.
I should have not been trying to run this regex at this stage of the 
script and, in
fact (I have been doing a lot of complex programming on this project ) I 
had
the same regex further down the list where is should have been and was 
already.
Anyhow, I think this may be valuable for anyone who is trying to learn 
by watching

and reading this list.
thanks
Jeff K

was not the answer to your question already given to you in one of your 
previous posts about this problem?


If you didn't get it, here it is again.

quote
You used to have the - after the 9 at the end, and then you
tacked on the \. and \/ after that, and now PCRE is trying to
use the - as if it were a range-specifier, like, a-z or 0-9,
only you've got, essentially, a-z0-9-.
quote

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



Re: [PHP] Re: Regex

2006-08-21 Thread Dave Goodchild

On 21/08/06, M. Sokolewicz [EMAIL PROTECTED] wrote:
A little harsh but I agree with the sentiment - plus you will get a lot of
pleasure out of it when you see how powerful a tool it is in your arsenal.




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


Re: [PHP] Re: Regex

2006-08-21 Thread J R

http://www.php.net/manual/en/reference.pcre.pattern.syntax.php

On 8/22/06, Alex Turner [EMAIL PROTECTED] wrote:


If what you mean is a db table, then it would seem to me that you should
not be using a regex.  PHP has rawurlencode() for this sort of thing.

But - you should learn regex ;-)

Try something like (untested and late at night)

function urlme($location)
{
 $enc=rawurlencode($location);
 $spc=htmlspecialchars($location);
 return A href='http://$enc'$spc/a;
}

AJ

www.project-network.com
www.deployview.com
www.funkifunctions.blogspot.com

M. Sokolewicz wrote:
 Nadim Attari wrote:
 Hello,

 I have some text in a table... the text contains hyperlinks (but not
 html coded, i.e. plain Some text...http://www.something.com;)

 When i retrieve these texts from the table, i want the hyperlinks to
 become clickable, i.e. a href etc added automatically.

 Some text...a
 href=http://www.something.com;http://www.something.com/a

 I know this sould be done using Regex, but i don't know regex.

 Any help (links, examples, etc)

 Thanks
 Nadim Attari

 You don't know Regex. Well, that's simple then, TRY to learn it. Noone
 will (or should) give you any answers if it's absolutely clear that
 you're not putting any effort into trying to find one yourself. I know
 this should be done using Regex, but I don't know regex., wouldn't you
 think it'd be a good idea to look up a tutorial somewhere or try to find
 out what this regex exactly is? Try to type regex in the php doc, see
 the notes for the various functions?

 really, a little more effort goes a long way.
 - tul

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





--
GMail Rocks!!!


Re: [PHP] Re: regex help and file question

2004-08-07 Thread PHP Gen

 Hi,
 
 I can't answer your regexp question but some
 thoughts on file() etc.:
 - file() returns the contents line by line as an
 array, so this makes only
 sense if you need the contents in this form, e.g.
 for looping through each
 line and applying a function or whatever
 - fread() requires a file handle that you have to
 create with fopen(), so
 file_get_contents() is kind of a shortcut for
 fopen()/fread()
 

Hey,

Thanks for replying and the answer to my second Q,
sounds like file_get_contents() is good for me now.

I think i found a solution for the regex too, just
have to modify some parts.

Cheers,
Mag

=
--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)




__
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

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



Re: [PHP] Re: regex help needed -- Solved! Thanks!

2004-08-02 Thread Fabrice Lezoray
Kathleen Ballard a écrit :
Thanks!  Works like a charm!
I am the very lowest of newbies when it comes to regex
and working through your solutions has been very
educational.  I have one question about something I
couldn't figure out: 

#h[1-9](.*)/h[1-9]#Uie
`h([1-6]).*?/h\1)`sie
What is the purpose of the back-ticks and the '#'? 
PCRE patterns has to be enclosed, you can use all the non alpha numerics 
characters to do that. Personnaly, I prefer back ticks because I don't 
have to escape it often inside my patterns.
For my example, you can also remove the ``s pattern modifier, It makes 
the dot ( . ) accept any New line characters, and I had not see  that 
you removed them before.

What are 'Uie' and  'sie'?
there are patterns modifiers, you can find a complete list and 
descriptions here :
http://www.php.net/manual/en/pcre.pattern.modifiers.php


Thanks again!
Kathleen
-Original Message-
From: Fabrice Lezoray [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 01, 2004 2:52 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: regex help needed 

hi
M. Sokolewicz a écrit :
You could try something like:
$return = preg_replace('#h[1-9](.*)/h[1-9]#Uie',
'str_replace(br 

/, , $1)');
- Tul
Kathleen Ballard wrote:

Sorry,
Here is the code I am using to match the h* tags:
h([1-9]){1}.*/h([1-9]){1}
I think this mask is better :
`h([1-6]).*?/h\1)`sie

I have removed all the NL and CR chars from the
string
I am matching to make things easier.  Also, I have
run
tidy on the code so the tags are all uniform.
The above string seems to match the tag well now,
but
I still need to remove the br tags from the tag
contents (.*).
To remove the br / tags, you need to call
preg_replace_callback() :
?php
$str = 'h1hi br / ../h1 bla bla h5  br /
../h5 ...br /';
function cbk_br($match) {
	return 'h' . $match[1] . '' . str_replace('br /',
'', $match[2]) . 
'/h' . $match[1] . '';
}
$return =
preg_replace_callback('`h([1-6])(.*?)/h\1`si',
'cbk_br', 
$str);
echo $return;
?

The strings I will be matching are html formatted
text.  Sample h* tags with content are below:
h4Ex-Secretary Mickey Mouse br /Loses Mass.
Primary/h4
h4Ex-Secretary Mickey Mouse br /Loses Mass.
Primary br / Wins New Jersey/h4
h4Ex-Secretary Reich Loses Mass. Primary/h4
Again, any help is appreciated.
Kathleen


Sorry for my bad english ..
--
Fabrice Lezoray
http://classes.scriptsphp.fr
-
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Re: regex help needed -- Solved! Thanks!

2004-08-01 Thread Kathleen Ballard

Thanks!  Works like a charm!

I am the very lowest of newbies when it comes to regex
and working through your solutions has been very
educational.  I have one question about something I
couldn't figure out: 

#h[1-9](.*)/h[1-9]#Uie
`h([1-6]).*?/h\1)`sie
What is the purpose of the back-ticks and the '#'? 
What are 'Uie' and  'sie'?

Thanks again!
Kathleen

-Original Message-
From: Fabrice Lezoray [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 01, 2004 2:52 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: regex help needed 

hi

M. Sokolewicz a écrit :
 You could try something like:
 $return = preg_replace('#h[1-9](.*)/h[1-9]#Uie',
'str_replace(br 
 /, , $1)');
 
 
 - Tul
 
 Kathleen Ballard wrote:
 
 Sorry,
 Here is the code I am using to match the h* tags:

 h([1-9]){1}.*/h([1-9]){1}
I think this mask is better :
`h([1-6]).*?/h\1)`sie



 I have removed all the NL and CR chars from the
string
 I am matching to make things easier.  Also, I have
run
 tidy on the code so the tags are all uniform.

 The above string seems to match the tag well now,
but
 I still need to remove the br tags from the tag
 contents (.*).
To remove the br / tags, you need to call
preg_replace_callback() :

?php
$str = 'h1hi br / ../h1 bla bla h5  br /
../h5 ...br /';
function cbk_br($match) {
return 'h' . $match[1] . '' . str_replace('br /',
'', $match[2]) . 
'/h' . $match[1] . '';
}
$return =
preg_replace_callback('`h([1-6])(.*?)/h\1`si',
'cbk_br', 
$str);
echo $return;
?


 The strings I will be matching are html formatted
 text.  Sample h* tags with content are below:

 h4Ex-Secretary Mickey Mouse br /Loses Mass.
 Primary/h4

 h4Ex-Secretary Mickey Mouse br /Loses Mass.
 Primary br / Wins New Jersey/h4

 h4Ex-Secretary Reich Loses Mass. Primary/h4

 Again, any help is appreciated.
 Kathleen


-- 
Fabrice Lezoray
http://classes.scriptsphp.fr

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



Re: [PHP] Re: Regex Help

2004-01-27 Thread karthikeyan.balasubramanian
Hi Ben,

  Your code works but If i remove the delimter [] which
I gave so that you could capture the data which needs to be
picked it doesnt work?.  Any help?

Karthikeyan B
- Original Message -
From: Ben Ramsey [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; Karthikeyan
[EMAIL PROTECTED]
Sent: Monday, January 26, 2004 11:56 PM
Subject: [PHP] Re: Regex Help


 Check the PHP manual for preg_match()
 (http://us3.php.net/manual/en/function.preg-match.php).

 I did play around with it a little bit, and I think I've got a starting
 point for you to work with.  Try out this code and then play around with
 it to get the results you need.  $matches[2][0] will hold the full line
 for Mayberry Mob.  You could then just use the substr() function to pull
 the data from that line.

 The code is, as follows:

 $subject = 
 =
 NF [1/21/04] E Race 11 Grade B [5-16] Going F

 U Too Tipsy  60½ 2 1 1 1   1 1   1 ½  30.46   4.40  Held Firm
Inside

 Dream Away   62  8 2 3 2   3 2 ½  30.51   17.90 Up For Plc
Mdtk

 Pounce N Bounce  70  5 4 2 1   2 3 2  30.58   4.50  Held Show
Inside

 Oneco Conor  67½ 7 8 4 5   4 4 2  30.60   6.90  Evenly Inside

 Krazy Kirk   70  4 3 6 7   5 5 5  30.79 * 1.90  Varied
 Little Mdtrk

 Mayberry Mob 73½ 1 6 5 6   6 6 10 31.15   5.30  Never
 Prominent Ins

 Jw Alley's Wish  60  3 7 8 9   7 7 10 31.17   6.50  No Factor
Mdtrk

 Rooftop Comet56  6 5 7 8   8 8 19 31.79   21.80 Never In It
Mdtk
 
 ;
 $pattern = /\[(\d+\/\d+\/\d+|\d+\-\d+)\]|(Mayberry Mob.*)/;
 if (preg_match_all($pattern, $subject, $matches, PREG_SET_ORDER)) {
 print_r($matches);
 } else {
 echo no match.;
 }

 Hope that helps!



 Karthikeyan wrote:

  Sorry last time I forgot to put subject on my mail.  So here
  I am putting appropriate subject and sending it.
 
  Hi All,
 
Just wondering if somebody can help me with this small regex search.
  The information I wanted to capture is the one in the Square Bracket.
  i.e Date : 1/21/04, Race Type: 5-16, Dog Position: 6(Mayberry Mob)
 
  =
  NF [1/21/04] E Race 11 Grade B [5-16] Going F
 
  U Too Tipsy  60½ 2 1 1 1   1 1   1 ½  30.46   4.40  Held Firm
  Inside
 
  Dream Away   62  8 2 3 2   3 2 ½  30.51   17.90 Up For Plc
Mdtk
 
  Pounce N Bounce  70  5 4 2 1   2 3 2  30.58   4.50  Held Show
  Inside
 
  Oneco Conor  67½ 7 8 4 5   4 4 2  30.60   6.90  Evenly
Inside
 
  Krazy Kirk   70  4 3 6 7   5 5 5  30.79 * 1.90  Varied
  Little Mdtrk
 
  [Mayberry Mob] 73½ 1 6 5 6   6 6 10 31.15   5.30  Never
  Prominent Ins
 
  Jw Alley's Wish  60  3 7 8 9   7 7 10 31.17   6.50  No Factor
Mdtrk
 
  Rooftop Comet56  6 5 7 8   8 8 19 31.79   21.80 Never In It
  Mdtk
  
 
  Looking forward to hear some response.
 
  Have a great day.
 
  Karthikeyan B
 

 --
 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] Re: Regex Help

2004-01-27 Thread Ben Ramsey
Why do you need to remove the delimeters?  If you remove them, then it 
makes it quite difficult to get the data you need.  If you want to 
display the date and race type without the square brackets around them, 
then use $matches[0][1] and $matches[1][1] instead of $matches[0][0] or 
$matches[1][0].



Karthikeyan.Balasubramanian wrote:
Hi Ben,

  Your code works but If i remove the delimter [] which
I gave so that you could capture the data which needs to be
picked it doesnt work?.  Any help?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: RegEx -- help

2003-10-10 Thread Robert Cummings
On Fri, 2003-10-10 at 16:18, Curt Zirzow wrote:
 On Fri, 10 Oct 2003 14:01:00 -0400 (EDT), Lists [EMAIL PROTECTED] wrote:
 
  I do not know if this is the right list, but if someone could help me 
  with the following
 
 Sure, I'll be glad to help.
 
 
  I need a function that does this:
 
 I'm not sure if you want me to write the code that does this for you, but I 
 know that I wont. I'm just going to give you the tools that are commonly
 used for the tasks your asking for.
 
 
  function phone($num) {
 
  take num and remove anything that is not a number
  ex: () - /
 
 http://php.net/preg_replace
 
 
 
  If there is not 1 at the start, add a one to the start of the number.
 
 http://php.net/substr
 
 
  make sure that the number is 10 digits (if not return -1)
 
 http://php.net/strlen
 
  }
 
  Thank you for your help,
 
 In the future, please at least try and attempt to write the code, most 
 people here arnt here to write code for everyone, but to solve problems 
 people are
 having with their own code.

Incidentally the procedure for correcting the number is flawed. If you
(original poster) have a 9 digit number with an area code beginning with
a 1 then the required additional 1 will never be prepended. Really what
you want is if the sequence of numbers is 9 digits long then precede
with a 1.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Re: regex problem

2003-08-15 Thread John W. Holmes
Merlin wrote:

^\/test\/contact.html$


does not work. I am sorry, I just found that

it has to be:
test/contact.html
and not
dir/test/contact.html
there is no leading slash.

Do you have any other suggestion?
Are you making this too hard?

if($string = 'test/contact.html')
{ echo 'good'; } else { echo 'bad'; }
??

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals  www.phparch.com





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


Re: [PHP] Re: regex problem

2003-08-15 Thread John W. Holmes
John W. Holmes wrote:
Merlin wrote:

^\/test\/contact.html$


does not work. I am sorry, I just found that

it has to be:
test/contact.html
and not
dir/test/contact.html
there is no leading slash.

Do you have any other suggestion?


Are you making this too hard?

if($string = 'test/contact.html')
That's

if($string == 'test/contact.html')

of course... :)

---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals  www.phparch.com





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


RE: [PHP] Re: regex problem

2003-08-15 Thread Jay Blanchard
[snip]
 if($string = 'test/contact.html')

That's

if($string == 'test/contact.html')

of course... :)
[/snip]

it could be

if($string == test/contact.html)

couldn't resist :)

Jay

P.S. John, nothing on that thing yet.

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



Re: [PHP] Re: regex problem

2003-08-15 Thread Kae Verens
Jay Blanchard wrote:
if($string == 'test/contact.html')

it could be

if($string == test/contact.html)
not to start a flame war or anything, but isn't the apostrophe version 
quicker, as it doesn't ask the server to parse the string?

Kae

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


Re: [PHP] Re: regex problem

2003-08-15 Thread Marek Kilimajer
So
^[^/]+/[^/]*
or

^!(partner/)

Merlin wrote:

ufff.. sorry guys, but I have to explain that better. I appreciate your
help, maybe I did not give enough info.
I am trying to redirect with apache modrewrite. To do this you have to use
regex (not if functions:-)
My problem is, that there are member accounts which look like that:

membername/contact.html

and there are partner accounts which look like this:

partner/name/contact.html

The goal is to redirect only if it is a member account. If I put a
(.*)/contact.html it also matches the partner/
I tryed putting a root / infront, but there is not / root for the url from
apaches point of view.
So I would need a regex which will match the member account, but if the
first word is partner it should
not terminate.
This seems to be a tough one!

Thanx for any help,

Merlin

Kae Verens [EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
Merlin wrote:

^\/test\/contact.html$


does not work. I am sorry, I just found that

it has to be:
test/contact.html
and not
dir/test/contact.html
there is no leading slash.

Do you have any other suggestion?

*sigh*

^test\/contact.html$

Kae







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


Re: [PHP] Re: regex problem

2003-08-15 Thread Merlin
does not work. Is there not a way to exclude the word partner like you
triede with !(partner) ?

merlin



Marek Kilimajer [EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
 So
 ^[^/]+/[^/]*

 or

 ^!(partner/)

 Merlin wrote:

  ufff.. sorry guys, but I have to explain that better. I appreciate your
  help, maybe I did not give enough info.
 
  I am trying to redirect with apache modrewrite. To do this you have to
use
  regex (not if functions:-)
 
  My problem is, that there are member accounts which look like that:
 
  membername/contact.html
 
  and there are partner accounts which look like this:
 
  partner/name/contact.html
 
  The goal is to redirect only if it is a member account. If I put a
  (.*)/contact.html it also matches the partner/
  I tryed putting a root / infront, but there is not / root for the url
from
  apaches point of view.
 
  So I would need a regex which will match the member account, but if the
  first word is partner it should
  not terminate.
 
  This seems to be a tough one!
 
  Thanx for any help,
 
  Merlin
 
  Kae Verens [EMAIL PROTECTED] schrieb im Newsbeitrag
  news:[EMAIL PROTECTED]
 
 Merlin wrote:
 
 ^\/test\/contact.html$
 
 
 does not work. I am sorry, I just found that
 
 it has to be:
 test/contact.html
 
 and not
 dir/test/contact.html
 
 there is no leading slash.
 
 Do you have any other suggestion?
 
 
 *sigh*
 
 ^test\/contact.html$
 
 Kae
 
 
 
 
 




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



Re: [PHP] Re: regex problem

2003-08-15 Thread Curt Zirzow
* Thus wrote Merlin ([EMAIL PROTECTED]):
 ufff.. sorry guys, but I have to explain that better. I appreciate your
 help, maybe I did not give enough info.
 
 I am trying to redirect with apache modrewrite. To do this you have to use
 regex (not if functions:-)

I'm not sure what you expect since this *is* a php mailing list.

 
 My problem is, that there are member accounts which look like that:
 
 membername/contact.html
 
 and there are partner accounts which look like this:
 
 partner/name/contact.html
 
 The goal is to redirect only if it is a member account. If I put a
 (.*)/contact.html it also matches the partner/
 I tryed putting a root / infront, but there is not / root for the url from
 apaches point of view.
 
 So I would need a regex which will match the member account, but if the
 first word is partner it should
 not terminate.
 
 This seems to be a tough one!

Mod rewrite is a powerful tool and you can accomplish what you are
doing several different ways.  As you can tell most people have
been giving attempts to fix your problem without success. This is
because it is not entirely clear what you need done.


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] Re: regex problem

2003-08-15 Thread Curt Zirzow
* Thus wrote Kae Verens ([EMAIL PROTECTED]):
 Jay Blanchard wrote:
 if($string == 'test/contact.html')
 
 it could be
 
 if($string == test/contact.html)
 
 not to start a flame war or anything, but isn't the apostrophe version 
 quicker, as it doesn't ask the server to parse the string?

heh, that is true. Although I havn't benched marked it but it
prolly is somewhere around .01 difference :)

your not the one that needs to be flamed, it seems that everytime a
topic of 'regex' is posted there is always 20+ in the thread with
101% of them not doing what the person wants. Not to mention the
OT'ness of the post.

cheers,

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



RE: [PHP] Re: regex problem

2003-08-15 Thread Wouter van Vliet
So, what you want is to pretty much use this regex

/^(.*)([^\/]+)\/([^\/]+)$/

when matched on this URI, the backreferences will contain

\\1 partner/
\\2 name
\\3 contact.html
\\4 .html

  partner/name/contact.html

I have not tested it, but I just guess it will work ;) Wanna know why? I'll
tell you :D

- It first looks at the beginning of the string and will go on untill a the
next pair of () start (partner/)
- That happens there where there is a string containing any character, but
not a slash (partner)
- as a seperator another slash is added
- it starts to match the last part of the url and looks up untill the end.
Again a string containing no slashes

Hope it does do what I expect it to do .. ;)

Wouter


-Oorspronkelijk bericht-
Van: Merlin [mailto:[EMAIL PROTECTED]
Verzonden: vrijdag 15 augustus 2003 16:21
Aan: [EMAIL PROTECTED]
Onderwerp: [PHP] Re: regex problem


Good idea,

but does not work either - surprisingly! -

There should be a clean way with regex for this task.


Andy regex expert in here?

Merlin



Kae Verens [EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
 Merlin wrote:
  ufff.. sorry guys, but I have to explain that better. I appreciate your
  help, maybe I did not give enough info.
 
  I am trying to redirect with apache modrewrite. To do this you have to
use
  regex (not if functions:-)
 
  My problem is, that there are member accounts which look like that:
 
  membername/contact.html
 
  and there are partner accounts which look like this:
 
  partner/name/contact.html
 
  The goal is to redirect only if it is a member account. If I put a
  (.*)/contact.html it also matches the partner/
  I tryed putting a root / infront, but there is not / root for the url
from
  apaches point of view.
 
  So I would need a regex which will match the member account, but if the
  first word is partner it should
  not terminate.
 
  This seems to be a tough one!
 

 ah - maybe a chain of rewrites would do?

 send all matches of /^partner\/(.*)\/contact.html$/ to partner\/\1\/blah
 send all matches of /^(.*)\/contact.html$/ to NEWLOCATION
 send all matches of /^partner\/(.*)\/blah$/ to partner\/\1\/contact.html

 Kae




--
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] Re: Regex Help with - ?

2003-06-27 Thread Gerard Samuel
sven wrote:

looks like id3v2 ;-)

how about this:
$string = [TIT2] ABC [TPE1] GHI [TALB] XYZ;
$pattern = /\[TIT2\]([^]*)/; // matches anything exept ''; till '' or
end of string
preg_match($pattern, $string, $match);
var_export($match);
Yeah, Im trying to figure out a way to parse these tags.

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


Re: [PHP] Re: Regex for Browser Versions

2003-06-06 Thread Gerard Samuel
True, but since the code is being run by 3rd parties, I don't have a 
guarantee that
the browsecap.ini file is available on the server.

Monty wrote:

Maybe it might be easier to just use the get_browser() function:

http://www.php.net/manual/en/function.get-browser.php

Monty



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


RE: [PHP] Re: regex problem

2003-06-03 Thread Ford, Mike [LSS]
 -Original Message-
 From: Monty [mailto:[EMAIL PROTECTED]
 Sent: 31 May 2003 21:21
 
 If you want the entire string to be tested for digits, you 
 need to add the
 length of the string to the regex pattern:
 
 $length = strlen($data);
 preg_match([0-9]{$length}, $data);

Or anchor the pattern to both start and end of the string:

  preg_match(^[0-9]+$, $data);

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] Re: REGEX for phone #

2002-07-29 Thread Analysis Solutions

Hi Richard:

On Mon, Jul 29, 2002 at 05:02:49AM -0500, Richard Lynch wrote:
 
 For starters, if Perl wants \ PHP needs \\ since \ is special in both
 languages.

I'm curiuos what you're talking about.  The manual says nothing about this
in the PCRE section:
   Example 1. Examples of valid patterns
  * \/\w+/
  * |(\d{3})-\d+|Sm
http://www.php.net/manual/en/ref.pcre.php

The Pattern Syntax page has a backslashes section which states: In
particular, if you want to match a backslash, you write \\.

Then, all of my patterns work just fine w/o escaping the backslashes.

So, uh, what are you talking about? :)

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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