Jump to content

[SOLVED] Two tags, gotta match them separately


Daedalian

Recommended Posts

Hello! I've got a small problem with regex.

 

I have a text with some code listings, with structure like this:

 

Bla bla bla lorem ipsum dolore sit amet. Bla bla bla lorem ipsum dolore sit amet. 

<code> lots of 

multilined

code</code>

Bla bla bla.

<code> lots of 

another

multilined

code</code>

 

I want to match both <code>'s. I do this way: /\<code\>.*\<\/code\>/s. It works, but it matches:

 

<code> lots of 

multilined

code</code>

Bla bla bla.

<code> lots of 

another

multilined

code</code>

 

While I want it to match:

<code> lots of 

multilined

code</code>

and

<code> lots of 

another

multilined

code</code>

 

Possibly this is somehow related to greedyness? I tried everything though, no success :(

Thanks in advance!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.