Jump to content

does not match pattern


GoneNowBye

Recommended Posts

okay i'm gonna simplfy it here, hence lack of codes, i've made some sort of markup language, rather then try and explain it, i'll just use html.

 

lets say i'm trying to parse html and i have

 

<div id="this">

</div>

<div id="that">

</div>

 

and you tell regex to match

(?:<div )([A-Za-z0-9= "_]*)>([\\[\\]=" ->a-zA-Z_]*)(?:</div>)

its fine but it matches

</div>

<div id="that">

 

not each div tag seperatly, how may i specify to REGEX dont match the end one match the ones between

Link to comment
Share on other sites

You can parse HTML with Regex, it is just generally not the best way. Normally far easier/simpler to use some kind of DOM. It sounds like what you are talking about is the difference between Greedy and Lazy pattern matching. By default a PCRE pattern is greedy, you need to make it lazy.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.