[PHP] Re: Regex

2012-07-27 Thread Al



On 7/27/2012 1:07 PM, Ethan Rosenberg wrote:

Dear list -

I've tried everything  and am still stuck.

A regex that will accept numbers, letters, comma, period and no other characters

Thanks.

Ethan Rosenberg





%[\w\d,.]%

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



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



[PHP] Re: Regex for extracting quoted strings

2011-03-05 Thread Nathan Rixham

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?


$regex = '/(.*)/imU';
$r = preg_match_all($regex, $sentence, $phrases);


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



[PHP] Re: Regex for extracting quoted strings

2011-03-05 Thread Shawn McKenzie
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

-- 
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);


[PHP] Re: Regex for ... genealogical names

2011-01-01 Thread Al



On 1/1/2011 4:46 AM, Lester Caine wrote:

JohnDoeSMITH' or 'John Doe SMITH'


Try this. not tested.

First, which adds spaces as needed. e.g. JohnDoeSMITH  'John Doe SMITH'

$newName=preg_replace(%(?=[a-z])([A-Z]),  $1, $name);//Cap following low
case, add space before it

Next, alphas following a cap, lower case them

function lowCase($matches){return strtolower($matches[1]);}

$newName= preg_replace_callback(%(?=[A-Z])([A-Z])%, lowCase', $newName);

Sorry don't have time today to test; but, this should get you started.


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



[PHP] Re: Regex for telephone numbers

2010-12-31 Thread Al



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 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



[PHP] Re: Regex Problem

2009-07-31 Thread Igor Escobar
The solution don't need to be with regex, if anyone can solve this with
other way will be very helpfull .


Regards,
Igor Escobar
Systems Analyst  Interface Designer

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





On Fri, Jul 31, 2009 at 2:23 PM, Igor Escobar titiolin...@gmail.com wrote:

 Hi Folks,
 I have a serious problem.

 must create a regular expression against all that is between single quote
 or double quotes. Easy? Ok, i know, but i need that everything must to be
 too an single quote or double quote.

 If i have this SQL command:

 SELECT * FROM TSTRENIC.MEI_ACESSO WHERE UPPER(DS_MEI_ACS) LIKE *'%NOME'
 ASD ' AS'ASD'%' *AND USUARIO = *'oaksdpokasd'asda'* ORDER BY DS_MEI_ACS
 ASC;

 SELECT * FROM TSTRENIC.MEI_ACESSO WHERE USUARIO_DATA BETWEEN *'2007-01-02'
 * AND *'2008-07-08'*

 Anyone have any idea?



 I need an expression which case the fields in bold.


 Regards,
 Igor Escobar
 Systems Analyst  Interface Designer

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






[PHP] Re: Regex Problem

2009-07-31 Thread Shawn McKenzie
Igor Escobar wrote:
 The solution don't need to be with regex, if anyone can solve this with
 other way will be very helpfull .
 
 
 Regards,
 Igor Escobar
 Systems Analyst  Interface Designer
 
 + http://blog.igorescobar.com
 + http://www.igorescobar.com
 + @igorescobar (twitter)
 
 
 
 
 
 On Fri, Jul 31, 2009 at 2:23 PM, Igor Escobar titiolin...@gmail.com wrote:
 
 Hi Folks,
 I have a serious problem.

 must create a regular expression against all that is between single quote
 or double quotes. Easy? Ok, i know, but i need that everything must to be
 too an single quote or double quote.

 If i have this SQL command:

 SELECT * FROM TSTRENIC.MEI_ACESSO WHERE UPPER(DS_MEI_ACS) LIKE *'%NOME'
 ASD ' AS'ASD'%' *AND USUARIO = *'oaksdpokasd'asda'* ORDER BY DS_MEI_ACS
 ASC;

 SELECT * FROM TSTRENIC.MEI_ACESSO WHERE USUARIO_DATA BETWEEN *'2007-01-02'
 * AND *'2008-07-08'*

 Anyone have any idea?



 I need an expression which case the fields in bold.


 Regards,
 Igor Escobar
 Systems Analyst  Interface Designer

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


Not entirely sure I understand.  You want to BOLD the things contained
in quotes and you put the * there to show that?  If so, this is not tested:

$bolded = preg_replace('#([\'])(.*?)\1#', 'b\1\2\1/b', $text);

-- 
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 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



[PHP] Re: Regex help

2008-09-09 Thread Nathan Rixham

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]

prehaps

--
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



[PHP] Re: regex

2008-08-13 Thread Philip Thompson

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 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



[PHP] Re: regex

2008-08-13 Thread Shawn McKenzie

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

--
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



[PHP] Re: Regex in PHP

2008-06-04 Thread Al

$user = trim(strstr($email, '@'), '@);


VamVan wrote:

Hello All,

For example I have these email addressess -

[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

What would be my PHP function[Regular expression[ to that can give me some
thing like

yahoo.com
hotmail.com
gmail.com

Thanks



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



[PHP] Re: Regex in PHP

2008-06-04 Thread Shawn McKenzie

VamVan wrote:

Hello All,

For example I have these email addressess -

[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

What would be my PHP function[Regular expression[ to that can give me some
thing like

yahoo.com
hotmail.com
gmail.com

Thanks




Or if you know that the address is valid and you may need both parts:

list($name, $domain) = explode('@', '[EMAIL PROTECTED]');


-Shawn

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



[PHP] Re: Regex for Advanced search feature

2007-10-19 Thread Al
Go here and get charprobe http://www.dextronet.com/charprobe.php  It's a super 
utility to have.


Look up the hex code for a space, /x20 as I recall.

Then pick a non-printable code that you like e.g., /x83 or a printable one that 
users cannot enter.


Then simply preg_replace(%/x20+%, /83, $string);//one or more spaces

If you want to preserve the number of spaces don't use +.


Kevin Murphy wrote:
I'm trying to create an advanced search feature for my site, and I have 
it mostly working the way I want. I take whatever search term 
($searchkey) that the user submits, explodes if off any spaces between 
words, and then use that to search for each word separately.


$keys = explode( ,$searchkey);

So the search phrase of:

Dog Cat Horse

would output :

Array
(
[0] = Dog
[1] = Cat
[2] = Horse
)

However, I would like to add the ability to have phrases in there 
indicated by  marks. So, if the search phrase was this:


Dog Cat Horse

It would output:

Array
(
[0] = Dog Cat
[1] = Horse
)

My concept to solve this is right before I explode the keys as above, to 
replace any spaces within  marks with a garbage string of characters 
(say XX) using a regular expression, and then later replace it 
back with a space. However, I suck at regular expressions and can't 
figure it out.


Anyone have a way for me to accomplish this with a regular expression or 
with another method?




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



[PHP] Re: Regex error

2007-03-14 Thread Al

Get The Regex Coach http://weitz.de/regex-coach/

Use preg_match_all()

Build your pattern one step at a time using the coach.  Don't forget the 
delimiters.

jekillen wrote:

Hello;
The following regex:

ereg(member value='[a-zA-Z ]{1,25}' uspace='([a-z0-9-\.\/]{2,11})' 
id='$m[1]', $groups, $m1);


is causing the following error:

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


Can someone tell me what this means?

What I am trying to do is pick out some info from an xml tag the is id'd by
$m[1] ( a match from a preceding regex. This regex is only supposed to
be applied if there is an $m[1] match. This happened without the
dot (.) and forward slash escaped in the uspace=' etc ' section. I used
back slashes to see if that made a difference, it does not. I have gotten
a little hazy on what needs to be escaped in character classes.

 I have written a number of
similar regexs in the same collections of scripts and I can not see what
this one is complaining about.
php v5.1.2, Apache 1.3.34, FreeBSD v6.0
Thanks in advance
Jeff K


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



[PHP] re regex error

2007-03-14 Thread jekillen

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

--
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



[PHP] Re: Regex

2006-08-23 Thread Nadim Attari

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


Hello,

I know i MUST learn it.. time does not permit me. But surely i'll learn 
how to use this powerful tool!


And if i didn't need a quick help from this ML, why i would be here ... 
do you think if time permitted me to learn this, i'll ask a little help 
from this ML ? I am learning and will continue to learn throughout my life.


And remember, the day one says i've learnt everthing now this is the 
day his downfall begins ...


Anyway i've got something working:

function hyperlinks($text = '', $class = 'link')
{
  $text = trim($text);

  if ($text != '')
  {
if (trim($class) != '') $class = ' class='.$class.'';

$in = array('`((?:https?|ftp)://\\S+)(\\s|\\z)`', 
'`([[:alnum:]]([-_.]?[[:alnum:]])[EMAIL PROTECTED]:alnum:]]([-_.]?[[:alnum:]])*\.([a-z]{2,4}))`');


$out = array('a href=$1'.$class.' target=_blank$1/a$2', 'a 
href=mailto:$1;'.$class.'$1/a');


$text = preg_replace($in, $out, $text);
  }

  return $text;
}

Renders http, https, ftp, mailto.

Thanks M. Sokolewicz and everyone.
Nadim Attari

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



[PHP] Re: Regex

2006-08-21 Thread Ivo F.A.C. Fokkema
On Mon, 21 Aug 2006 13:51:16 +0400, 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

How's this:

?php
// $s contains the entry from the table.

// Non-strict url matching.
$s = preg_replace('/(http:\/\/[^\s]+)/i', A href=\$1\$1/A, $s);
?

This is very non strict. Anything starting with http:// until the next
whitespace (\s) is clickable. You might want to put a more strict rule in
there, but it depends on the text your searching in. Note that above code
does not work when an url is at the end of a line, and followed by a
period (.).

Ivo

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



[PHP] Re: Regex

2006-08-21 Thread M. Sokolewicz

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



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


[PHP] Re: Regex

2006-08-21 Thread Alex Turner
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



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!!!


[PHP] Re: RegEx drop everything after last pattern

2005-12-23 Thread Al

John Nichel wrote:
Okay, maybe it's just the fact that I'm concentration on getting out of 
here for the holidays more than I am on my work, but I'm pulling my hair 
out.  Say I have a string -


Now, is the time; for all good men! to come to the aide? of their

What I want to do is drop everything after (and including) the last 
punctuation mark (? in this case).  I've got my pattern to match any 
punctuation mark, but I just can't get the last one (it always hits on 
the first).  I'd love to use the string functions, but it has to be a 
regular expression (right now it's punctuation, but eventually it's 
going to need to be just about anything; last new line, last white 
space, last 'b', etc).




Consider using preg_split() and then array_pop()

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



[PHP] Re: Regex for balanced brackets?

2005-11-22 Thread Al

Jeffrey Sambells wrote:

I came across this method of matching brackets with regex in .NET

http://puzzleware.net/blogs/archive/2005/08/13/22.aspx

but I am wondering if it is possible to do the same in PHP?

I've tried it a bit but I can't seem to get it to work properly. I'm  
just wondering if I am doing something wrong or if it is just not  
possible.


Thanks.

here is the code I was playing with:

?php

$pattern = PATTERN
\{
(?
[^{}]+
|
\{ (?PDEPTH)
|
\} (?P-DEPTH)
)*
(?(DEPTH)(?!))

\}
PATTERN;

$subject = SUBJECT
test {
test2 {
test3
}
}

test4
{

}
SUBJECT;


preg_match_all(/$pattern/ix,$subject,$matches);

header(content-type: text/plain; );

var_dump($matches);

?


- Jeff



~~
Jeffrey Sambells
Director of Research and Development
Zend Certified Engineer (ZCE)

We-Create Inc.
[EMAIL PROTECTED] email
519.745.7374 office
519.897.2552 mobile

~~
Get Mozilla Firefox at
http://spreadfirefox.com


If I'm understanding what you want, consider this.  I use it to check matching 
tags.

First get an array of all the start tags:

$pattern= %([^/][a-z_\-]*)%i;   //all start tags used xxx

preg_match_all($pattern, $text_str, $matches);

$start_tags= $matches[1];

$start_tag_nums= array_count_values($start_tags);   //get count for each tag

Then do the same for your end tags, using the same pattern but with the end tag 
slash. /

Finally, you make a text list of the mismatches:

foreach($start_tag_nums as $tag= $num){

if($num != $end_tag_nums[$tag]) $end_error_msg .= lt;$taggt; || ;

}//end foreach

echo $end_error_msg;

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



[PHP] Re: regex and global vars problem

2005-10-27 Thread Al

Jason Gerfen wrote:
I am having a problem with a couple of function I have written to check 
for a type of string, attempt to fix it and pass it back to the main 
function.  Any help is appreciated.


?php

/*
* ex. 00:AA:11:BB:22:CC
*/
function chk_mac( $mac ) {
if( ( eregi( 
^[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}$, 
$mac ) ) || ( !eregi( ^[0-9a-fA-F]$, $mac ) ) {

 return 0;
} else {
 return 1;
}
}

/*
* check validity of MAC  do replacements if necessary
*/
function fix_mac( $mac ) {
global $mac;

if( eregi( ^[0-9A-Fa-f-\:]$, $mac ) ) {
$mac1 = $mac;
echo MAC: $mac1br;
   }

   /* strip the dash  replace with a colon */
if( eregi( 
^[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}$, 
$mac ) ) {

 $mac1 = preg_replace( /\-/, :, $mac );
 echo MAC: $mac1br;
   }
  /* add a colon for every two characters */
if( eregi( ^[0-9A-Fa-f]{12}$, $mac ) ) {
 /* split up the MAC and assign new var names */
 @list( $mac_1, $mac_2, $mac_3, $mac_4, $mac_5, $mac_6 ) = @str_split( 
$mac, 2 );

 /* put it back together with the required colons */
 $mac1 = $mac_1 . : . $mac_2 . : . $mac_3 . : . $mac_4 . : . 
$mac_5 . : . $mac_6;

 echo MAC: $mac1br;
}
return $mac1;
}

// do our checks to make sure we are using these damn things right
$mac1 = 00aa11bb22cc;
$mac2 = 00-aa-11-bb-22-cc;
$mac3 = 00:aa:11:bb:22:cc;
$mac4 = zz:00:11:22:ff:xx;

if( chk_mac( $mac1 ) != 0 ) {
$mac = fix_mac( $mac1 );
   echo $mac1 .  converted to  . $mac . br;
} else {
echo $mac1 is valid.br;
}

if( chk_mac( $mac2 ) != 0 ) {
$mac = fix_mac( $mac2 );
   echo $mac2 .  converted to  . $mac . br;
} else {
echo $mac2 is valid.br;
}

if( chk_mac( $mac3 ) != 0 ) {
$mac = fix_mac( $mac3 );
   echo $mac3 .  converted to  . $mac . br;
} else {
echo $mac3 is valid.br;
}

if( chk_mac( $mac4 ) != 0 ) {
$mac = fix_mac( $mac4 );
   echo $mac4 .  converted to  . $mac . br;
} else {
echo $mac4 is valid.br;
}


?



For what it's worth..

I'm moderately good with regex; but, I wouldn't even try to get an expression like yours to work properly, with all 
possiblities and exceptions.


Suggest breaking it up into several separate tests.

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



[PHP] Re: RegEx - Is this right?

2005-10-16 Thread Oliver Grätz
I don't know if these are equal.
What about \r\n line endings?
And what about \r line endings (from old Macs)?
I guess file() handles all of these cases (didn't test it though)
and your code doesn't (with \r you'll get a one line file!).

AllOlli

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



[PHP] Re: REGEX Help Please

2005-09-19 Thread Mark Rees
 I am trying to implement a regular expression so that I have a number
 between 0.00 and 1.00. the following works except I can go up to 1.99

 $regexp = /^[0-1]{1}.[0-9]{2}/;


You could always do this, unless you are set on using a regular expression:

if($num=0  $num=1.01){
 echo number_format($num,2);
}

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



[PHP] Re: Regex help

2005-06-06 Thread Al

RaTT wrote:
Hi Guys, 


I am currently creating a once off text parser for a rather large
document that i need to strip out bits of information on certain
lines.

The line looks something like :


Adress line here, postcode, country Tel: +27 112233665 Fax: 221145221
Website: http://www.urlhere.com E-Mail: [EMAIL PROTECTED] TAGINCAPS: CAPS
RESPONSE Tag2: blah


I need to retreive the text after each marker i.e Tel: Fax: E-Email:
TAGINCAPS: ...

I have the following regex /Tel:\s*(.[^A-z:]+)/ and
/Fax:\s*(.[^A-z:]+)/ all these work as expected and stop just before
the next Tag. However I run into hassels  around the TAGINCAPS as the
response after it is all in caps and i cant get the Regex to stop just
before the next tag: which may be either all caps or lowercase.

I cant seem to find the regex that will retreive all chartures just
before a word with a :  regalrdless of case.

I have played around with the regex coach but still seem to be comming
up short so i thought i would see if anybody can see anything i might
have missed.

any help most appreciated. 

Regards 
Jarratt


Add and i for case insensitive for all except the numbers type e.g.,

/TAGINCAPS:\s*(.[A-z:]+)/i

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



[PHP] RE: regex question

2005-05-17 Thread Carl Furst
I think there maybe a few ways to do this... One is

[EMAIL PROTECTED]@[EMAIL PROTECTED]

That basically says find me the pattern where one non-at symbol is followed
by an at symbol followed by another non-at symbol

So if you do 

?php

$string = @ one more T@@me for @ and i@ the Bl@@dy [EMAIL PROTECTED];


$pattern = '/[EMAIL PROTECTED](@)[EMAIL PROTECTED]/';

$numMatch = preg_match_all($pattern, $string, $matches);

echo numMatch: $numMatch\n;
print_r ($matches);

?

numMatch: 3
Array
(
[0] = Array
(
[0] =  @ 
[1] = i@ 
[2] = [EMAIL PROTECTED]
)

[1] = Array
(
[0] = @
[1] = @
[2] = @
)

)

Well, where that fails is when you have @'s at the beginning or end of the
string and that's easy enough to do.. So that would mean three searches...
There's probably a way to integrate them into one without loosing integrity,
but it depends on what kind of regexp libs you have, I reckon. It also
depends on what you really are trying to do with this search. Consider
str_replace, strpos and strtr as well.

Thanks,


Carl
-Original Message-
From: Al [mailto:[EMAIL PROTECTED] 
Sent: Monday, May 16, 2005 3:54 PM
To: php-general@lists.php.net
Subject: regex question

What pattern can I use to match ONLY single occurrences of a character in a
string.

e.g., Some text @ and some mo@@re and [EMAIL PROTECTED], etc @@@.

I only want the two occurrences with a single occurrence of @.

@{1} doesn't work; there are 4 matches.

Thanks

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



[PHP] Re: Regex help

2005-01-28 Thread Stian Berger
On Fri, 28 Jan 2005 14:59:29 -0700, [EMAIL PROTECTED] wrote:
OK, this is off-topic like every other regex help post, but I know some
of you enjoy these puzzles :)
I need a validation regex that will pass a string. The string can be no
longer than some maximum length, and it can contain any characters except
two consecutive ampersands () anywhere in the string.
I'm stumped - ideas?
TIA
Kirk
if(preg_match(/^([^]|(?!)){1,42}$/,$string)) {
This one will work I think.
Returns false if it finds two consecutive  or exceeds 42 chars.
--
Stian
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Regex Parsing

2004-12-05 Thread M. Sokolewicz
[EMAIL PROTECTED] wrote:
I wish to improve upon my regular expression skills.  I am creating a journal
object that allows me to post my journals online, while at the same time
maintaining nine different levels of privacy.  For example, if I give a user
Level 3 access, then they would be able to see all parts of my entries marked
as Level 3 or below, but nothing above that.
Below is an example entry.  I'm not sure how to go about doing this.  My
experience with regular expressions is somewhat limited.  I could use a
statement like this:
ereg([LEVEL1].*[/LEVEL1], $Contents, $Match);
But if you look at the contents below, you'll see that there are two places
where [/LEVEL1] is at, so that statement will mark the entire page as Level
1, rather than just the first sentence, and the last sentence.
Plus, that statement won't really work.  I need a way to say:  Replace
[LEVEL1].*[/LEVEL1] with ###LEVEL1### and return the contents into an array
for me.  That way, in the second phase of parsing, I can either put the
string back into the page at exactly the same point, or I can put Level 1
Access Required - Log In instead.
Any help would be greatly appreciated.  Thank you in advance.
[LEVEL1]Level 1 Access Required to view this section of this entry.[/LEVEL1]
between levels
[LEVEL2]Level 2 Access Required to view this section of this entry.[/LEVEL2]
between levels
[LEVEL3]Level 3 Access Required to view this section of this entry.[/LEVEL3]
between levels
[LEVEL4]Level 4 Access Required to view this section of this entry.[/LEVEL4]
between levels
[LEVEL5]Level 5 Access Required to view this section of this entry.[/LEVEL5]
between levels
[LEVEL6]Level 6 Access Required to view this section of this entry.[/LEVEL6]
between levels
[LEVEL7]Level 7 Access Required to view this section of this entry.[/LEVEL7]
between levels
[LEVEL8]Level 8 Access Required to view this section of this entry.[/LEVEL8]
between levels
[LEVEL9]Level 9 Access Required to view this section of this entry.[/LEVEL9]
Between levels
[LEVEL1]Level 1 Access Required to view this section of this entry.[/LEVEL1]
between levels
preg_match_all('#\[LEVEL([0-9])\](.*)\[/LEVEL[0-9]]#Uim', $content, 
$matches);

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


[PHP] Re: Regex Parsing

2004-12-05 Thread [ rswfire ]
 preg_match_all('#\[LEVEL([0-9])\](.*)\[/LEVEL[0-9]]#Uim', $content,
$matches);


You make it look so easy, thanks!  That takes care of step one, but how do I
make it so everything in $content where there is a level set, is replaced
with ###LEVEL?###

Does #Uim tell it to only get the first [/LEVEL1] rather than going to the
bottom and getting the second?  I've always wondered how to tell it to get
the first, rather than the last...

Thanks in advance!

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



[PHP] Re: Regex Parsing

2004-12-05 Thread M. Sokolewicz
[EMAIL PROTECTED] wrote:
preg_match_all('#\[LEVEL([0-9])\](.*)\[/LEVEL[0-9]]#Uim', $content,
$matches);
You make it look so easy, thanks!  That takes care of step one, but how do I
make it so everything in $content where there is a level set, is replaced
with ###LEVEL?###
Does #Uim tell it to only get the first [/LEVEL1] rather than going to the
bottom and getting the second?  I've always wondered how to tell it to get
the first, rather than the last...
Thanks in advance!
U means it'll become UNgreedy (means it ends at the first occurence 
instead of the last),
m means multiline, so . also matches \n and \r chars.
i means it's case-INsensitive. Which I thought was just useful ;)

print_r($matches) will show what comes out exactly how. Then at some 
point you'll probably be able to echo something like echo 
'###LEVEL'.$matches[1][$i].'###';
where $i would be the part you're echoing from.

Anyway, it'll be SOMETHING like that. I tend to always print_r the 
results first, and then write more code based on the result.

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


[PHP] Re: regex help and file question

2004-08-07 Thread Torsten Roehr
Php Gen [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi,
 I am just starting out with regex (and classes) so am
 not sure how to do this...

 I am seeing if a HTML file exists, if yes, I am using
 file_get_contents to get the entire HTML file into a
 string.

 In the HTML file I already have this:

 !-- Start header --
 html
 body
 whatever you want comes here
 !-- End header --

 How do I use a regex to span these multiple lines and
 simply cut everything (including the start..end
 part)from !-- Start header -- to !-- End header --

 Second question:
 I am using file_get_contents, is it better to use this
 than file() or fread() ?

 Thanks,
 Mag

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()

Hope this helps.

Regards, Torsten Roehr

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



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


[PHP] Re: regex help needed

2004-08-01 Thread M. Sokolewicz
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 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 (.*).
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: regex help needed

2004-08-01 Thread Fabrice Lezoray
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 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



[PHP] Re: regex problem

2004-07-01 Thread Lars Torben Wilson
Josh Close 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);
First, the short version. You can fix this by using backreferences:
 $string = preg_replace(/([^\r])\n/i, \\1\r\n, $string);
Now, the reason:
preg_replace() replaces everything which matched, so both the \n and
the character before it will be replaced (as they both had to match
to make the pattern match).
Luckily, preg_replace() stores a list of matches, which you can use
either later in the same pattern or in the replace string. This is
called a 'backreference'. You can tell preg_replace() which part(s) of
the pattern you want to store in this fashion by enclosing those parts
in parentheses.
In your case, you want to store the character before the \n which matched,
so you would enclose it in parentheses like so: /([^\r])\n/i. Thereafter
you can refer to that portion of the pattern match with the sequence \1.
If you add another set of parens, you would refer to it with \2...and so
on. You can even nest pattern matches like this, in which case they are
counted by the opening paren. So the replacement string would then become
\\1\r\n. (You need the extra \ in front of \1 to prevent PHP's string
interpolation parsing the \1 before it gets passed to preg_replace()).
A lot more information is available from the manual page on preg_replace():
  http://www.php.net/preg_replace
There is also an extensive pages on pattern syntax:
  http://www.php.net/manual/en/pcre.pattern.syntax.php
Hope this helps,
Torben
$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


[PHP] Re: regex problem

2004-07-01 Thread Josh Close
Thanks, that's exactly what I was looking for.

-Josh

On Thu, 01 Jul 2004 15:17:41 -0700, Lars Torben Wilson [EMAIL PROTECTED] wrote:
 
 Josh Close 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);
 
 First, the short version. You can fix this by using backreferences:
 
   $string = preg_replace(/([^\r])\n/i, \\1\r\n, $string);
 
 Now, the reason:
 
 preg_replace() replaces everything which matched, so both the \n and
 the character before it will be replaced (as they both had to match
 to make the pattern match).
 
 Luckily, preg_replace() stores a list of matches, which you can use
 either later in the same pattern or in the replace string. This is
 called a 'backreference'. You can tell preg_replace() which part(s) of
 the pattern you want to store in this fashion by enclosing those parts
 in parentheses.
 
 In your case, you want to store the character before the \n which matched,
 so you would enclose it in parentheses like so: /([^\r])\n/i. Thereafter
 you can refer to that portion of the pattern match with the sequence \1.
 If you add another set of parens, you would refer to it with \2...and so
 on. You can even nest pattern matches like this, in which case they are
 counted by the opening paren. So the replacement string would then become
 \\1\r\n. (You need the extra \ in front of \1 to prevent PHP's string
 interpolation parsing the \1 before it gets passed to preg_replace()).
 
 A lot more information is available from the manual page on preg_replace():
 
http://www.php.net/preg_replace
 
 There is also an extensive pages on pattern syntax:
 
http://www.php.net/manual/en/pcre.pattern.syntax.php
 
 Hope this helps,
 
 Torben
 
 
 
  $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



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


[PHP] Re: Regex Help

2004-01-26 Thread Ben Ramsey
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] Re: Regex help please

2004-01-11 Thread Manuel Vázquez Acosta
Try this:
$pattern = '#function
(\w+)\(((?:\$\w+(?:,\s*\$\w+)*?)|\s*)\)\s*\{[.\s]*((?:return\s+[^;]*\s*;)|)[
.\s]*#m';

Notice that \w means:
A word character is any letter or digit or the underscore character, that
is, any character which can be part of a Perl word.

Though, any regexp for this task can be easily fooled; i.e: there's no
regexp for all cases; PHP's language cannot be described properly using just
a regular expression.

Manu.


Shawn McKenzie [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I have tried numerous variations, but my regex skills suck!  I would
 appreciate anyone who can give me a pattern to use in preg_match_all() to
 match the following (I have the first part up to ANYTHING working):

 '|function ([\w\d\_]+)\((.*)\)ANYTHINGreturn (ANYTHING);|'

 So parsing a PHP file I hope to have 3 backreferences that return the
 function name, function args and return value (if present) of all
 functions.

 Thanks!
 -Shawn


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



[PHP] Re: Regex to grab a Windows Path from a String...

2003-12-17 Thread Sven
[EMAIL PROTECTED] schrieb:
My regex skills are serious lacking and after scouring the net for
relevant links I'm a bit stuck.  I've got a textarea field where I pull
user input from, and I'd like to search this entire field for a Windows
Directory Path (ex. C:\Documents\Blah).
Basically my users are allowed to specify HTML img tags in this textarea
and I'd like to make sure that they don't reference any images that are on
their local hard drive (which many of them are doing and then thinking
the HTML that I generate from that actually works when it doesn't).
Suggestions?

hi,

i would start like this:

1. get the entire src-param of your img tag:

?php
$regex = '/src=([^])/';
?
this should search for everything between the two doubleqoutes and give 
it as $match[1] if working with this param in preg_match().

2. check this string for url or local path:

some possibilities are, to check for backslashes, as they are only 
allowed in win-paths, not in url. or to check whether your path starts 
with a letter, followed by a colon ('/[a-zA-Z]:/') as the local root 
(drive letter). if both is false assume that it's a relative or absolute 
url.
the other (better?) way is, to check generally, whether it's a valid url 
according to rfc1738 (a local win-path isn't). maybe there are existing 
functions?

hth SVEN

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


[PHP] Re: RegEx -- help

2003-10-10 Thread Curt Zirzow
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.

--
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



[PHP] Re: regex/preg_replace() difficulty

2003-10-01 Thread Jon Kriek
You need to escape the period . twice with backslashes \\

-- 
Jon Kriek
http://phpfreaks.com

Jonas_weber @ Gmx . Ch [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Regular Expressions: How can I indicate that the contents of a term
 (user input*) needs to be treated as 'non-operators/control characters'
 (as *word* to match in that exact way)?
 (* Because the term is a user's input I can't escape the control
 characters manually.)

 Example:
 $result =
preg_replace('/('.$termWithOptionalBold.')(\/?span[^]*)*()/si', 'span
class=highlight\1/span', $result);

 [If $termWithOptionalBold is a . (period) for example, any char will
 be matched--instead of only the .]

 Any suggestions?


 Thanks a lot for your effort!
 Best wishes,
 jonas


 PS: Somewhere I read that '\Q' would do something like that but it
 didn't work.

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



[PHP] Re: regex problem

2003-08-15 Thread Kae Verens
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$
but it does not work and I tryed thousands of other ways plus read
tutorials.
Can anybody please help?
^\/test\/contact.html$

Kae

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


[PHP] Re: regex problem

2003-08-15 Thread Merlin
 ^\/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?

--
lt;IFRAME
SRC=http://saratoga.globosapiens/associates/report_member.php?u=3color=EEE
EEE scrolling=no frameborder=0 TITLE=My travel articles width=330
height=155  ALLOWTRANSPARENCY=truea href=http://www.globosapiens.net;
title=Worldwide Travel CommunityaTravel Communitya/ /IFRAME

Kae Verens [EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
 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$
 
  but it does not work and I tryed thousands of other ways plus read
  tutorials.
 
  Can anybody please help?

 ^\/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 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


[PHP] Re: regex problem

2003-08-15 Thread Kae Verens
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 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



[PHP] Re: regex problem

2003-08-15 Thread Merlin
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 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


[PHP] Re: regex problem

2003-08-15 Thread Kae Verens
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


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



[PHP] Re: regex problem

2003-08-15 Thread Merlin
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



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



[PHP] Re: regex help?

2003-07-21 Thread sven
hi john,
try a regex like this:
'/td[^]*(.*)/td/i'
ciao SVEN

John Herren wrote:
 Can't seem to get this to work...

 trying to yank stuff xxx from
 TD class=a8b noWrap align=middle width=17 bgColor=#ccxxx/TD

 and stuff yyy from

 TD class=a8b noWrap width=100nbsp;yyy/TD

 preg_match(|nbsp;(.*)/TD$|i, $l, $regs);

 works for the second example, even though it isn't the correct way,
 but nothing works for for me for the first example.

 Any help is appreciated!



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



[PHP] Re: Regex help needed

2003-07-16 Thread Nomadeous
First, the prob you got : WARNING 
comes from the following error:
(\s+face=\Verdana, Arial, Helvetica, sans-serif\|)
After the | (OR) sign, you must define another case, example:
echo eregi_replace (tr bgcolor=\#F8F8F1\(\s*)td\s*font 
size=\2\(\s+face=\Verdana, Arial, Helvetica, 
sans-serif\|\s)\s*purchasing power parity, '%POWER%', 
'tdtrsdsdsstr bgcolor=#f8f8f1 face=Verdana, Arial, Helvetica, 
sans-seriftdfont size=2Purchasing power parity');

Secondly, it's right that the \s expression is not recognised in
 purchasing\s+power\s+parity  , a little strange, but you can use two 
different ways instead of '\s':
 - [[:space:]]
 - [ ]
The brackets allows you to define a sequence of characters patterns (in 
the second case above, the space character).
It will give:
echo eregi_replace (tr bgcolor=\#F8F8F1\(\s*)td\s*font 
size=\2\\s*purchasing[[:space:]]+power[[:space:]]+parity, '%POWER%', 
'tdtrsdsdsstr bgcolor=#f8f8f1tdfont size=2Purchasing power 
parity');

Just a little help, you can find on the page 
http://www.php.net/manual/en/ref.regex.php that could be useful for you:

^ Start of line
$ End of line
n? Zero or only one single occurrence of character 'n'
n* Zero or more occurrences of character 'n'
n+ At least one or more occurrences of character 'n'
n{2} Exactly two occurrences of 'n'
n{2,} At least 2 or more occurrences of 'n'
n{2,4} From 2 to 4 occurrences of 'n'
. Any single character
() Parenthesis to group expressions
(.*) Zero or more occurrences of any single character, ie, anything!
(n|a) Either 'n' or 'a'
[1-6] Any single digit in the range between 1 and 6
[c-h] Any single lower case letter in the range between c and h
[D-M] Any single upper case letter in the range between D and M
[^a-z] Any single character EXCEPT any lower case letter between a and z.
Pitfall: the ^ symbol only acts as an EXCEPT rule if it is the
very first character inside a range, and it denies the
entire range including the ^ symbol itself if it appears again
later in the range. Also remember that if it is the first
character in the entire expression, it means start of line.
In any other place, it is always treated as a regular ^ symbol.
In other words, you cannot deny a word with ^undesired_word
or a group with ^(undesired_phrase).
Read more detailed regex documentation to find out what is
necessary to achieve this.
[_4^a-zA-Z] Any single character which can be the underscore or the
number 4 or the ^ symbol or any letter, lower or upper case
?, +, * and the {} count parameters can be appended not only to a single 
character, but also to a group() or a range[].

therefore,
^.{2}[a-z]{1,2}_?[0-9]*([1-6]|[a-f])[^1-9]{2}a+$
would mean:
^.{2} = A line beginning with any two characters,
[a-z]{1,2} = followed by either 1 or 2 lower case letters,
_? = followed by an optional underscore,
[0-9]* = followed by zero or more digits,
([1-6]|[a-f]) = followed by either a digit between 1 and 6 OR a
lower case letter between a and f,
[^1-9]{2} = followed by any two characters except digits
between 1 and 9 (0 is possible),
a+$ = followed by at least one or more
occurrences of 'a' at the end of a line.
Sid a écrit:
Hello,
Well I am doing by first reg ex operations and I am having problems 
which I just cannot figure out.

For example I tried
echo eregi_replace (tr bgcolor=\#F8F8F1\(\s*)td\s*font 
size=\2\\s*purchasing power parity, '%POWER%', 'tdtrsdsdsstr 
bgcolor=#f8f8f1tdfont size=2Purchasing power parity');
and this worked perfectly,

but when I chnaged that to
echo eregi_replace (tr bgcolor=\#F8F8F1\(\s*)td\s*font 
size=\2\\s*purchasing\s+power\s+parity, '%POWER%', 
'tdtrsdsdsstr bgcolor=#f8f8f1tdfont size=2Purchasing power 
parity');
It does not detect the string. Srange. According to what I know, \s+ 
will detect a single space also. I tried chnaging the last 2 \s+ to \s* 
but this did not work also.
Any ideas on this one?

As I proceed I would like the expression to detect the optional face 
attribute also, so I tried
echo eregi_replace (tr bgcolor=\#F8F8F1\(\s*)td\s*font 
size=\2\(\s+face=\Verdana, Arial, Helvetica, 
sans-serif\|)\s*purchasing power parity, '%POWER%', 
'tdtrsdsdsstr bgcolor=#f8f8f1 face=Verdana, Arial, Helvetica, 
sans-seriftdfont size=2Purchasing power parity');
... and this gave me an error like
Warning: eregi_replace(): REG_EMPTY:çempty (sub)expression in 
D:\sid\dg\test.php on line 2

Any ideas? BTW any place where I can get started on regex? I got a perl 
book that explains regex, but I have got to learn perl first (I dont 
know any perl)

Thanks in advance.

- Sid

Sid a écrit:
Hello,

Well I am doing by first reg ex operations and I am having problems which I just cannot figure out.

For example I tried
echo eregi_replace (tr bgcolor=\#F8F8F1\(\s*)td\s*font size=\2\\s*purchasing power parity, '%POWER%', 
'tdtrsdsdsstr bgcolor=#f8f8f1tdfont size=2Purchasing power parity');
and this worked perfectly,
but when I chnaged that to
echo eregi_replace (tr bgcolor=\#F8F8F1\(\s*)td\s*font 

[PHP] Re: Regex nightmare:(

2003-07-10 Thread sven
Tim Steele wrote:
 i need to uses reg ex to change a href=url to a href=url
 target=_blank

 the  brackets have to be represented using lt; and gt;

 I have tried so many ways, but none work. here is an example of my
 faliure.

 $body =
 preg_replace(/(href=\/?)(\w+)(gt;\/?)/e,'\\1'.'\\2'./'target=_blank/
 '.'\\3', $body);

 Thanks

did i understand you correct? you search in real html-code (with '' and
'') and want to replace them later by 'lt;' and 'gt;'?

- if so, your regex can't find any gt;. either you search for an '' or you
use htmlspecialchars() or htmlentities() to convert these brackets before.
- also, if in your href= stands a full url (with
scheme://domain.tld) your '\w' doesn't work
- what are the optonal escaped slashes for? '\/?'

hope this helps for your start:
$body = 'a href=http://www.url;';
$body = preg_replace ('/()(a href=[^]+)()/', 'lt;\\2
target=_blankgt;', $body);
var_export($body);

ciao SVEN



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



[PHP] Re: Regex Help with - ?

2003-06-27 Thread sven
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);

hint to your regex:
either use quantifier '*' (0-n times) OR '?' (0-1 times)

ciao SVEN

Gerard Samuel [EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
 I have a string something like -
 [TIT2] ABC [TPE1] GHI [TALB] XYZ
 Im applying a regex as such -
 // Title/Songname/Content
 preg_match('/\[TIT2\](.*?)(\[)?/', $foo, $match);
 $title = trim( $match[1] );

 The above regex doesn't work.  At the end of the pattern Im using (\[)?
 The pattern may or may not end with [
 For example searching for - [TALB] XYZ
 The string, is *NOT* expected to hold a certain order as how it is
 retrieved.
 How does one go about to fix up this regex?

 Thanks




-- 
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


[PHP] Re: Regex for Browser Versions

2003-06-06 Thread Monty
Maybe it might be easier to just use the get_browser() function:

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

Monty

 From: [EMAIL PROTECTED] (Gerard Samuel)
 Newsgroups: php.general
 Date: Thu, 05 Jun 2003 14:00:23 -0400
 To: [EMAIL PROTECTED]
 Subject: Regex for Browser Versions
 
 Im trying to pull the Mozilla version and *possibly* the MSIE x.xx
 string out $_SERVER['HTTP_USER_AGENT']
 If I did this correctly, (MSIE\s\d\.\d{1,2})? should mean that if its
 there pull it out, else move on, since its not there.
 When viewing this script via a windows browser, it doesn't match the
 MSIE section.  If I take out the trailing ?, it will match successfully.
 But when viewing it with a mozilla browser, the regex fails as there is
 not MSIE string in there.
 Any help with this would be appreciated.
 Thanks
 
 ?php
 
 var_dump($_SERVER['HTTP_USER_AGENT']);
 echo 'p';
 preg_match('/^(Mozilla\/\d\.\d{1,2}|Opera\/\d\.\d{1,2})\s\(.*?(MSIE\s\d\.\d{1,
 2})?.*?\)(\sOpera)?/',
 $_SERVER['HTTP_USER_AGENT'], $foo);
 
 var_dump($foo);
 
 ?
 


-- 
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



[PHP] Re: regex problem

2003-06-01 Thread Monty
I don't understand what it is you're trying to accomplish, so, it's hard to
offer a solution. If you just want to verify whether or not a variable
contains numeric data, why not just use the is_numeric() function:

http://us4.php.net/manual/en/function.is-numeric.php

preg_match() will return TRUE if it finds the pattern ANYWHERE in the
string, so, that's why asdf789 passes the test because it contains digits,
whereas 'asdf' won't pass the test because the numbers 0-9 can't be found
anywhere in that string.

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);

Monty

 From: [EMAIL PROTECTED] (Daniel J. Rychlik)
 Newsgroups: php.general
 Date: Sat, 31 May 2003 13:46:44 -0500
 To: [EMAIL PROTECTED]
 Subject: 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] Re: regex question?

2003-02-24 Thread Shawn McKenzie
Anyone?  please?

Thanks!
Shawn

Shawn McKenzie [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I'm using the following to try and replace urls in my html output:

 $newhrefs = preg_replace(/script.php\?(.*)=(.*)(.*)=(.*)(.*)=(.*)/,
 script-$1-$2-$3-$4-$5-$6.html, $hrefs);

 This works fine as long as there are exactly 3 var=val pairs... not 1 or 2
 or 4 or more...

 How can I write my expression to match 1 or more pairs???  For example:

 script.php?var=val
 script.php?var=valvar2=val2
 script.php?var=valvar2=val2var3=val3
 etc...etc...etc...

 TIA,
 Shawn





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



[PHP] Re: regex

2003-02-07 Thread Paul Chvostek
On Fri, Feb 07, 2003 at 05:29:49PM +0100, Marian Feiler wrote:
 
 i have to check if there's a dot in a string, and i need nothing but the
 regex pattern for this... tryed a lot, but the dot itself means to matches
 all.

You can escape the dot either by putting a backslash in front of it or
putting it inside square brackets.  So:

ereg(a.b,aaabbb);

is true, but

ereg(a[.]b,aaabbb);

is false.  Other sensitive characters can also be escaped in this way;
the bracket expression [][.^$()|*+?-] matches any of those characters.
And to match any *except* those characters, use [^][.^$()|*+?-].

Check the re_format(7) man page for details.  If you don't have a unix
box handy, check http://www.freebsd.org/cgi/man.cgi?query=re_format .

-- 
  Paul Chvostek [EMAIL PROTECTED]
  Operations / Abuse / Whatever
  it.canada, hosting and development   http://www.it.ca/


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




[PHP] Re: Regex question

2002-12-12 Thread Paul Chvostek

On Thu, Dec 12, 2002 at 11:01:47PM -0800, Troy May wrote:

 How would take a regular non-formatted text link (http://www.link.com) and
 turn it into ready to post HTML? (a 
href=http://www.link.comhttp://www.link.com/a)

 Darn, Outlook formats it, but you get the idea.  It would just be typed out
 normally.

How about:

$href=(https?://([a-z0-9]+\.)+[a-z][a-z]+/[a-z0-9_./~%-]*);
$repl=a href='\\1'\\1/a;
$line=eregi_replace($href, $repl, $line);

You can of course make $href less restrictive if you're liberal minded
about your URL formats.

-- 
  Paul Chvostek [EMAIL PROTECTED]
  Operations / Abuse / Whatever  +1 416 598-
  it.canada - hosting and development  http://www.it.ca/


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




[PHP] Re: Regex for split() to split by , which is not in ()s?

2002-09-17 Thread David Robley

In article [EMAIL PROTECTED], eurleif@buyer-
brokerage.com says...
 I'm looking for a regex which splits a string by commas, but only if the 
 comma is not in parenthesis.   I know I'm being lazy and should write it 
 myself, but that's just it... I'm lazy!

Well, as it happens I'm too lazy to write it for you :-)

-- 
David Robley
Temporary Kiwi!

Quod subigo farinam

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




[PHP] Re: regex help

2002-09-05 Thread Richard Lynch

?php

$str = 'hi bmy friend/b! br / this message uses html entities a 
href=http://www.trini0.org;test/a!';
$str = preg_replace('/(a href=http:\/\/.*.*\/a)/', 
htmlspecialchars($1), $str);

Maybe I'm missing something here, but can't you just do:

$str = htmlspecialchars($str);

-- 
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




  1   2   >