Dom World Chat Champion
Joined: 06 Sep 2004 Karma :
|
Posted: 14:29 - 03 Feb 2006 Post subject: Question for any programmers (Warning: Very dull) |
|
|
I don't suppose any BCFers know their way around regular expressions do they?
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. If anyone can help I will owe them big time... I've wasted so long on this it's crazy. ____________________ Photos and that |
|
KevlarPants Nova Slayer
Joined: 21 Jan 2005 Karma :
|
|
Dom World Chat Champion
Joined: 06 Sep 2004 Karma :
|
Posted: 14:39 - 03 Feb 2006 Post subject: |
|
|
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. Cheers dude, that was the push in the right direction that I needed.
Code: | (\[div class="mosimage_caption").*?(\[/div\]) |
____________________ Photos and that |
|
Suzuki Roger
Joined: 03 May 2005 Karma :
|
Posted: 14:45 - 03 Feb 2006 Post subject: |
|
|
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\]]*
EDIT/ your way is neater. ____________________ <Simple> no I'm shaven Jon
<Simple> it is a big enough hole.. I'll leave it now
Ride: 1999 Suzuki GSXR600 (yellow/black) IRC: Stats - Relationship Map |
|