[thelist] Regex help

Dan Parry dan at virtuawebtech.co.uk
Mon Nov 26 13:52:29 CST 2007


> > -----Original Message-----
> > From: Dan Parry
> > Sent: Monday, November 26, 2007 2:19 PM
> >
> > It breaks because of the whitespace in the text attribute...
> > Now, it seems
> > to me I have 2 options:
> >
> > 1) Replace whitespaces in attributes with a different
> > character (not my
> > chosen solution)
> >
> > 2) Break the attributes apart (into an array with format
> > 'key="Value"') and
> > deal with each attribute separately (preferred option)
> >
> > For the life of me I'm not able to figure out the regex to do
> > either (which
> > is odd because usually regexes are my 'Rainman' syndrome)
> >
> > The proposed regex need only focus on the 'attributes' not
> > the 'tag name'
> 
> 
> Hi Dan,
> 
> The trick is to use a regex that is designed from the ground-up to
> match the
> definition from the RFC.  Here's a bit of information on Regex's for
> matching HTML tags in a very robust fashion:
> 
> http://concepts.waetech.com/unclosed_tags/

Thanks, that does help... Unfortunately not specifically enough for this
usage (well, for me anyway :) )

I'm not working from an RFC so I'm defining the input... What I'm really
asking is how do I split this:

val1="Value one" val2="Second value"

into (pseudo)

Array() {
   (1) = 'val1="Value one"';
   (2) = 'val2="Second value';
}

Bearing in mind that quotes can be single (') or double (") (type-matching
isn't important at this time)

> That code is for CF, but the concepts should be consistent for PHP.

It is perfect for PHP... And is some great reading... I'm sure I'll get some
good tips

Thanks!

Dan

> Joshua
> 
> 
> --
> 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
> 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.503 / Virus Database: 269.16.7/1151 - Release Date:
> 25/11/2007 16:24
> 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.16.7/1151 - Release Date: 25/11/2007
16:24
 




More information about the thelist mailing list