Firstly,

If your text spans more than one line you should use
\n, rather than just doing something like :

<a href=\"
hello\">...(.*)</a>

because that will mess up, depending on what text
editor you use, eg. notepad will put \r\n, but it
should only be \n. Though I'm not sure about it.

So the best solution is :

<a href=\"\nhell\">...(.*)</a>

Now that said, let's look into your problem, you
mention you want "one" common regex that does both of
them. That would be tideous enough to let be, instead
using two distinct regex checks would be easier, and
faster.

So :

eregi('<para font-size="12" font-family="Arial"
style="heading 2">(.*)<anchor
type="bkmrk"/>(.*)</para>', $string, $matches);

would store "Some" in $matches[1], "more text-" in
$matches[2].

eregi('<para font-size="12" font-family="Arial"
style="heading 2"><inline
caps="false">(.*)</inline>(.*)</para>', $string,
$datex);

would store "Some text" in $datex[1], "more text" in
$datex[2]

Now if you want to know which one to execute, just do
a

if(eregi('<inline caps="false">', $input_string)) {

execute_this_Regex();

}

It should be faster this way, and an even more
efficient solution can be using Perl Regex.

HTH

Mukul Sabharwal
http://www.dehvome.org


----- Original Message ----- 
From: "David Pratt" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, August 12, 2003 10:55 AM
Subject: [PHP] Regex help appreciated


> I am trying to get a regex to extract the "Some" and
"more text" 
> between the para elements below in a single pass for
style attribute of 
> heading 2
> 
> <para font-size="12" font-family="Arial"
style="heading 2">Some<anchor 
> type="bkmrk"/>more text-</para>
> 
> <para font-size="12" font-family="Arial"
style="heading 2"><inline 
> caps="false">Some text</inline>more text</para>
> 
> Tried something like this for first bit but grabbing
the anchor tag 
> with the text.
> 
> |<para(.*)style=\"heading
2\"">(([a-zA-Z0-9/-/_/&\s]+)?)([<anchor 
> type="bkmrk" name="[a-zA-Z0-9/_]+"/>])?(.*)</para>|
> 
> Help much appreciated.
> Thanx
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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

Reply via email to