Resend my activation email : Register : Log in 
BCF: Bike Chat Forums


Question for any programmers (Warning: Very dull)

Reply to topic
Bike Chat Forums Index -> The Geek Zone
View previous topic : View next topic  
Author Message

Dom
World Chat Champion



Joined: 06 Sep 2004
Karma :

PostPosted: 14:29 - 03 Feb 2006    Post subject: Question for any programmers (Warning: Very dull) Reply with quote

I don't suppose any BCFers know their way around regular expressions do they? Confused

Atm I'm having an absolute nightmare trying to make one which will find the following code inside some HTML:

Code:

[div class="mosimage_caption" style="width: ; text-align: center;" align="center"]Tamada on the RC211V[/div]


The problem is, the caption (text in between the divs) and the div parameters will vary (with the exception of "<div class="mosimage_caption"") so it's tricky as hell to get to work.

My best attempt so far is:

Code:
(\[div class="mosimage_caption").*(\[/div\])


But that always matches everything right up to the last instance of [/div] because of the .* code which is matching everything and then backtracking... I need it to match just up to the first instance of [/div].

Fecking hate these things. Evil or Very Mad If anyone can help I will owe them big time... I've wasted so long on this it's crazy.
____________________
Photos and that
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts

KevlarPants
Nova Slayer



Joined: 21 Jan 2005
Karma :

PostPosted: 14:32 - 03 Feb 2006    Post subject: Reply with quote

You should look into 'non greedy' matching, for the regex engine you are using.

Not a lot of help, but hopfully a pointer in the right direction...
 Back to top
View user's profile Send private message You must be logged in to rate posts

Dom
World Chat Champion



Joined: 06 Sep 2004
Karma :

PostPosted: 14:39 - 03 Feb 2006    Post subject: Reply with quote

I'd looked into that a bit but not had a clue what to do. Bit of investigating into PHP and it seems all I needed was an extra question mark. Very Happy Cheers dude, that was the push in the right direction that I needed. Thumbs Up

Code:
(\[div class="mosimage_caption").*?(\[/div\])

____________________
Photos and that
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts

Suzuki
Roger



Joined: 03 May 2005
Karma :

PostPosted: 14:45 - 03 Feb 2006    Post subject: Reply with quote

Easy. In your .* for matching the bit inbetween the divs, rather than saying "anything" you need to say "anything except a /div tag".

So, replace the .* with something like [^\[\/div\]]*

Very Happy

EDIT/ your way is neater. Thumbs Up
____________________
<Simple> no I'm shaven Jon Razz
<Simple> it is a big enough hole.. I'll leave it now
Ride: 1999 Suzuki GSXR600 (yellow/black) IRC: Stats - Relationship Map
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts
Old Thread Alert!

The last post was made 18 years, 103 days ago. Instead of replying here, would creating a new thread be more useful?
  Display posts from previous:   
This page may contain affiliate links, which means we may earn a small commission if a visitor clicks through and makes a purchase. By clicking on an affiliate link, you accept that third-party cookies will be set.

Post new topic   Reply to topic    Bike Chat Forums Index -> The Geek Zone All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Read the Terms of Use! - Powered by phpBB © phpBB Group
 

Debug Mode: ON - Server: birks (www) - Page Generation Time: 0.07 Sec - Server Load: 0.42 - MySQL Queries: 17 - Page Size: 43.77 Kb