[Javascript] regexp - how to exclude a substring?

Shawn Milo shawn.milo at gmail.com
Sun May 22 00:33:57 CDT 2005


Paul,

On 5/21/05, Paul Novitski <paul at novitskisoftware.com> wrote:
> Shawn,
> 
> Thanks very much for taking the time to help.  I blush to confess that it's
> not actually JavaScript I'm using but PHP -- I took the liberty of posting

That's fine with me. I consider this to be my 'home list,' so I may run a little
off-topic from time to time myself.  ;o)

> 
> Pending the discovery of the right piece of regexp to do my parsing for me,
> I've used a temporary solution that's very much like what you suggest: I
> split the HTML into an array at every < (not >) so that each array element
> begins with either DIV or /DIV; then I walk the array beginning with my

Are  you splitting on '<' or '<div'? Because if it's the first, then
how are you making
sure that you deal only with divs? 

> 
> The purpose of this is to extract segments of an HTML template for
> selective processing.
> 
Can you give more detail? If so, maybe we can be of more help.

> You say:
> >I believe that regex lookaheads and lookbehinds are not supported in
> >Javascript.
> 
> Why would such be necessary in order to determine whether a matched pair of
> <div/</div occurred within a string?  It seems like what I really need to
> know is how to say in regexp, "match this string if it contains any
> character but NOT the substring "</TAG"".  With that tool, I can filter for
> nested TAGs inside my parent TAG.
Because  a lookbehind should, in theory allow for a regex to say
"find any /div that is not preceeded by a /div earlier in the string."
If we could do that, then we could cut out the hassle of having to
split on every tag. Unless my thinking is faulty, which is a consideration
at this late hour.

I'll watch this thread for more developments, and join in as I am able.
Tomorrow, after sleep.  :o)

Shawn



More information about the Javascript mailing list