-2

i want to know something about RegEx, yeah I'm a new ReGex user. Okay here is my problem. I have a string like this

< a href = 'howdy.html' class     =  'pt-nght' >

and I want to get an array that contains

array[0] = "href = 'howdy.html'"

array[1] = "class = 'pt-nght'"

I tried to use this ReGex

 [^<\s*(.*)]\s*(.*)\s*=\s*(.*)\s*[^>]

but the result seems to be far away from what i expect. Or may be there is any other technique ? Thank you :)

Yoshua Joo Bin
  • 517
  • 3
  • 6
  • 15
  • Sounds like you're going down a dark path towards this: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags – jerluc Nov 14 '14 at 03:25
  • There is other technique, sure. It is DOM parsing with DOM parser, without regexps... And sure you that `< a` is a valid element? – vp_arth Nov 14 '14 at 03:35

1 Answers1

0

You may have a better time using DOMDocument, but you could also try:

[^\s]+?\s*=\s*'.*?'
Explosion Pills
  • 188,624
  • 52
  • 326
  • 405