Jump to content


Photo

*SOLVED* Matching Quotes -- Effigy, where are you???


  • Please log in to reply
2 replies to this topic

#1 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 10 October 2006 - 06:45 PM

ok, here's the situation, i am struggling to come up with something that will match all quotes not contained within an HTML tag. sounds pretty straight forward, right? well, as variable length look behinds are not supported yet, i'm really struggling with how best to do this. is there anyone that can come up with a way to handle this with a single regular expression for preg_match_all(), or do i need to do this incrementally?
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 11 October 2006 - 01:54 PM

What about this? It's not quotes, but it has the same concept of isolating the HTML tags from the regex.

I don't think this can be done with a single regex unless recursive callbacks are used.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 11 October 2006 - 01:57 PM

What about this? It's not quotes, but it has the same concept of isolating the HTML tags from the regex.

I don't think this can be done with a single regex unless recursive callbacks are used.


excellent. i was hoping to be able to do it all with a preg_replace(), but from what i understand after checking with a couple gurus here at work, it's not possible with a single regular expression without variable length lookaround support.

thanks for the quick fix, though!
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users