Re: [PHP] regular expressions php/perl/actionscript

2004-04-22 Thread David Scott
I believe Regular Expressions are language independent. Here is an 
O'Reilly book on the matter:
http://www.oreilly.com/catalog/regex2/

Chris W. Parker wrote:
Gabino Travassos 
on Thursday, April 22, 2004 12:24 PM said:

I'm wondering if Regular Expressions are the same in Perl and PHP (and
possibly Actionscript)? They look the same and smell the same, but if
I see a book in a store for Perl Regular Expressions that's $10
cheaper than the PHP one (is there one?), then is it the same thing?


i'd get the perl book over the php book personally. but then again i'm
pretty sure there is not a "perl regex" book, nor is there a "php regex"
book. there's probably just a regex book. you as the user have to decide
what works where.
this page will tell you what php supports:

http://us3.php.net/ereg


While we're on this topic, I'm looking to find an attribute in an XML
and replace it with a string variable I get from a form.


check the other functions on that page. your answer is there!



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


Re: [PHP] regular expressions php/perl/actionscript

2004-04-22 Thread Curt Zirzow
* Thus wrote Gabino Travassos ([EMAIL PROTECTED]):
> Hello
> 
> I'm wondering if Regular Expressions are the same in Perl and PHP (and
> possibly Actionscript)? They look the same and smell the same, but if I see
> a book in a store for Perl Regular Expressions that's $10 cheaper than the
> PHP one (is there one?), then is it the same thing?

PHP's PCRE (Perl Compatible Regular Expressions).

http://php.net/pcre

Some of the documentation there can get a little bit like reading a
complex regular expression.  A good book might help:

  http://www.oreilly.com/catalog/regex2/index.html


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] regular expressions php/perl/actionscript

2004-04-22 Thread Gabino Travassos

Thanks for the suggestions. Between the online manual and the books I have I
think I'll get there eventually. Sometimes my logic just sux. What I needed
to do was have the user fill out a form and if they make changes to the XML
file I would update the file. So, my long way around was to go through the
old XML file and create a string variable for every possible form field.
Then I would compare the /bgClrOld/ to /bgClr/ and if they were different I
would then update the file with an ereg_replace.

After some poking around, this seems to be the way to go. Only if the field
is not empty so I change it

if ($bgClr !=""){
$bgClr="xx";
}

I still have some work to do, but ...

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



RE: [PHP] regular expressions php/perl/actionscript

2004-04-22 Thread Michal Migurski
> > I'm wondering if Regular Expressions are the same in Perl and PHP (and
> > possibly Actionscript)? They look the same and smell the same, but if
> > I see a book in a store for Perl Regular Expressions that's $10
> > cheaper than the PHP one (is there one?), then is it the same thing?
>
> this page will tell you what php supports:
>
> http://us3.php.net/ereg

Alternatively, try this:
http://www.php.net/manual/en/ref.pcre.php

"PCRE" == "Perl-compatible Regular Expressions".

The ereg functions use a slightly different syntax.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] regular expressions php/perl/actionscript

2004-04-22 Thread Gabino Travassos
I forgot to mention that in my XML file, inside the quotes in this attribute
>>> backColour="xx"  the x's will be variable..., so I need some kind of
wildcard to select everything from "backColour" + the next 8 or 9
characters, cuz it might be backColour="333990" or whatnot.

'backColour' will be a unique string in the XML file, but I'll have those
quotes and a variable RGB hex value to find and replace.

Can I do something like
$bgClrOld = ereg_match('/backColour/'+8chr,$s);
?

Merci

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



Re: [PHP] regular expressions php/perl/actionscript

2004-04-22 Thread John W. Holmes
From: "Gabino Travassos" <[EMAIL PROTECTED]>

> I'm wondering if Regular Expressions are the same in Perl and PHP (and
> possibly Actionscript)? They look the same and smell the same, but if I
see
> a book in a store for Perl Regular Expressions that's $10 cheaper than the
> PHP one (is there one?), then is it the same thing?

The regular expressions used in the preg_* functions "closely resembles
Perl". The basic syntax is the same. The regular expressions used in the
ereg_* functions are POSIX-Extended.

http://us2.php.net/manual/en/ref.pcre.php (Perl-compatible)
http://us2.php.net/manual/en/ref.regex.php (POSIX Extended)

---John Holmes...

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



RE: [PHP] regular expressions php/perl/actionscript

2004-04-22 Thread Chris W. Parker
Gabino Travassos 
on Thursday, April 22, 2004 12:24 PM said:

> I'm wondering if Regular Expressions are the same in Perl and PHP (and
> possibly Actionscript)? They look the same and smell the same, but if
> I see a book in a store for Perl Regular Expressions that's $10
> cheaper than the PHP one (is there one?), then is it the same thing?

i'd get the perl book over the php book personally. but then again i'm
pretty sure there is not a "perl regex" book, nor is there a "php regex"
book. there's probably just a regex book. you as the user have to decide
what works where.

this page will tell you what php supports:

http://us3.php.net/ereg

> While we're on this topic, I'm looking to find an attribute in an XML
> and replace it with a string variable I get from a form.

check the other functions on that page. your answer is there!



chris.

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



[PHP] regular expressions php/perl/actionscript

2004-04-22 Thread Gabino Travassos
Hello

I'm wondering if Regular Expressions are the same in Perl and PHP (and
possibly Actionscript)? They look the same and smell the same, but if I see
a book in a store for Perl Regular Expressions that's $10 cheaper than the
PHP one (is there one?), then is it the same thing?

While we're on this topic, I'm looking to find an attribute in an XML and
replace it with a string variable I get from a form.

I can use:
$bgClrOld = preg_match('/backColour/',$s);  //  1
to find the attribute, but how do I find and replace
   backColour="a3b4c5"
with
   backColour=$bgClrNew
?

TIA

Gabino

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