Sid <[EMAIL PROTECTED]> wrote:
> 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%', '<td><tr>sdsdss<tr 
> bgcolor="#f8f8f1"><td><font size="2">Purchasing 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%', '<td><tr>sdsdss<tr 
> bgcolor="#f8f8f1"><td><font size="2">Purchasing 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?


I'd do something like this, unless your string must have to have the 
attributes to the html elements.

<tr[^>]*>[[:space:]]*<td[^>]*>[[:space:]]*<font[^>]*>[[:space:]]*purchasing[[:space:]]*power[[:space:]]*parity

> 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%', '<td><tr>sdsdss<tr bgcolor="#f8f8f1" face="Verdana, Arial, 
> Helvetica, sans-serif"><td><font size="2">Purchasing 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

(\s+face=\"Verdana, Arial, Helvetica, sans-serif\"|)>\s*purchasing power parity
the problem is regex is expecting something here---^

you can change it to:
(\s+face=\"Verdana, Arial, Helvetica, sans-serif\">|>)\s*purchasing power parity

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

Go right to the source:
http://www.oreilly.com/catalog/regex/

> 
> Thanks in advance.
> 
> - Sid

Curt
-- 


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

Reply via email to