0

I need the regex that returns the following from a webpage's code, I'm searching whithin Dreamweaver in the code of the page:

<body>
**** lines of HTML code (anything)***
<div class="pg">

sorry I'm into a situation that only regex is the solution, i'm so new to it.

z403
  • 67
  • 6
  • 2
    Don't parse HTML with a regex: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 Instead, parse the DOM. –  Sep 28 '11 at 16:56
  • 3
    But when I want to search within code using Dreamweaver and the only option is "Use Regular Expression". – z403 Sep 28 '11 at 16:59
  • If you're trying to extract certain elements from your HTML, then use a DOM Parser (eg PHP's DOMElement (http://php.net/manual/en/class.domelement.php)). –  Sep 28 '11 at 17:00
  • 1
    @Jack: Do you understand the difference between parsing and textual search? How would PHP help in Dreamweaver? – user123444555621 Sep 28 '11 at 18:02
  • @Pumbaa80 - Yes, I do. Why should he pick out HTML elements in Dreamweaver? –  Sep 28 '11 at 18:14

1 Answers1

1

You could try something like:

<body>[\s\S]*<div> class="pg">

you need [\s\S] because . probably won't match \n (unless Dreamweaver has a checkbox for multiline mode or something)

Nick Knowlson
  • 7,185
  • 6
  • 47
  • 63