I do not know, how to understand the topic (title) I have something like this:
& lt; H2 & gt; Title & lt; / H2 & gt; & Lt; & Lt; Navigation ID = "submenu" & gt; & Gt; & Lt; & Lt; Main level = "1" asd = "2" & gt; & Gt; & Lt; & Lt; Main level = "1" asd = "2" & gt; & Gt; & Lt; & Lt; Notmain & gt; & Gt; Asd & lt; & Lt; / Notmain & gt; & Gt; & Lt; & Lt; / Navigation & gt; & Gt; & Lt; P & gt; & Lt; A href = ".." & gt; Eddie & lt; / A & gt; Asdasdasd & lt; / P & gt; Oh no! The great rabbit is attacking us, and we are only the knights of a square table! & Lt; H2 & gt; There can be another tag here & lt; / H2 & gt; & Lt; & Lt; Footer & gt; & Gt; & Lt; & Lt; Copyright ID = "Copy" & gt; & Gt; & Lt; & Lt; / Footer & gt; & Gt;
I should know and remember (in the form of text) objects in which there are two tags (but only the main parent). So for this example, I want some output like this:
array (0 = & gt; ' gt; & gt; Lt; & lt; main level = "1" SD = "2"> gt; gt; & gt; notmain & gt; & gt; Eddy gt; & lt; / navigation & gt; & gt; '1 = & gt;' & lt; Piter & gt; & gt; & lt ; & Lt; Copyright ID = "copy"> >> <> >
Spaces and white spaces, And tab, and the rest do not matter, because it trim, and using str_replace It is easy to touch. Only one problem is searching the method.
I was trying to start it again but there are some problems.
- Only me Parents are interested in it, so any recursive search for ''
- Before me No information about the word is found, it can be & lt;> and then return all :). I do not know, and no solution has been found if regex can remember what it has been found.
I hope my question is clear. Thx for reply!
PS I am using php for this, and I know php (quite well), so text solutions without code, or even ideas will be useful.
PS2 If there is a solution without any regex, it would be great, surely there is a brute force solution (character after analyzing the character), but there are many codes in it ...
How about:
% ^ & lt; & Lt; ([^ & Lt;] +?) & Gt; & Gt; $ (. +?) ^ & Lt; & Lt; ([^ & Lt;] +?) Receives this result when used with
preg_match_all
array (0)
= & gt; Array (0 = & gt; 'lt; & lt; Navigation id = "submenu"> gt; & lt; main level = "1" asd = "2"> gt; & gt; Main Level = "1" ADS = "2"> gt; & lt; No & gt; AD & lt; / lt; / notmain> & gt; & lt; / lt; / navigation & gt; & gt; 1 = & gt; & # 39; Piter & gt;; & gt; & lt; & lt; Copyright ID = "Copy" & gt; & gt; & lt; / footer & gt; & gt; ,), 1 = & gt; Array (0 = & gt; "Navigation ID =" Submenu ", 1 = & gt; 'Footer',), 2 = & gt; array (0 = & gt; 'lt; & lt; main level =' 1 < Lt; >, 1 = gt; '& lt; & lt; copyright id = "copy"> gt; & gt; array, = & Gt; '/ navigation', 1 = & gt; '/ footer',),)
Comments
Post a Comment