开发者

RegExp - Grabbing only the important information from a string

开发者 https://www.devze.com 2023-01-04 19:48 出处:网络
I tried the following at http://gskinner.com/RegExr, there it worked perfectly. Now I want to get the /(?<=>\\r\\s{23})(.*)/gi pattern realized in PHP. The > character don\'t perform well, a

I tried the following at http://gskinner.com/RegExr, there it worked perfectly. Now I want to get the /(?<=>\r\s{23})(.*)/gi pattern realized in PHP. The > character don't perform well, also not with backslashes...

I want to get the &nbsp;&nbsp;2011&nbsp;Oct&nbsp;3, Mon, Unity Day and &nbsp; in the mi开发者_Go百科d of every <FONT></FONT>.

Searching string:

      `<TR>
         <TD ALIGN=LEFT VALIGN=MIDDLE HEIGHT=17 
              WIDTH=175  BGCOLOR=lightblue>
               <FONT COLOR=red SIZE=2>
                   &nbsp;&nbsp;2011&nbsp;Oct&nbsp;3, Mon
               </FONT>
         </TD>
         <TD ALIGN=LEFT VALIGN=MIDDLE HEIGHT=17 
              WIDTH=150 BGCOLOR=lightblue>

         <FONT COLOR=black SIZE=2>
                   Unity Day
               </FONT>
         </TD>
         <TD ALIGN=LEFT VALIGN=MIDDLE HEIGHT=17 
              WIDTH=275 BGCOLOR=lightblue>
         <FONT COLOR=black SIZE=2>
                   &nbsp;
               </FONT>
         </TD>

     </TR>`

Any ideas, other solutions, etc.?

Greetings Eminenz


This will be echoed many times on stack overflow - don't use regex to parse XML/HTML.

Check out the DOM parser: http://www.w3schools.com/php/php_xml_dom.asp

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号