-2

Possible Duplicate:
How to parse and process HTML with PHP?
How to parse HTML with PHP?

I am trying to get what's inside a body tag using regex, but it doesn't work in some cases.

For example if a web page has:

<body>text</body>

it will work, but it won't work if the body tag has a class or something defined, like

<body class="something">text</body>

I need the regex to work on both cases.

Community
  • 1
  • 1
Special K.
  • 521
  • 1
  • 8
  • 18

1 Answers1

2

Use [^>]*> after 'body' word:

<body[^>]*>.*</body>
grodzik
  • 264
  • 3
  • 10