Support » Plugin: Text Hover » Matching within HTML Tags

  • I’ve seen a few other posts here on this but not a solution. Sorry if I should add to those threads.

    My specific use case is for abbreviations within table cells. Often that’s just <td>ABBR</td> (or a th or a strong) without any spaces.

    I looked at the regex but… not gonna happen! I was wondering if anyone out there had figured out a pattern to use that would include text within > and < but, of course, not between < and >. Come to think of it, by editorial convention, all of the acronyms in the project I’m working on are UPPER case and, by nerd convention, all of my code is in lowercase so there’s not really a chance for HTML tag collision.

    Alternatively, if anyone can think of a way to filter table cells to pad the content with spaces via filter before Text Hover does it’s magic, I’m listening!

    https://wordpress.org/plugins/text-hover/

Viewing 1 replies (of 1 total)
  • Thread Starter syrupcore

    (@syrupcore)

    Well, I tried this and it seems to be working. I took out the negative look aheads and added > and < to either side main capture. In some brief testing it seems to be fine but my Regex Fu is weak enough that I’m not entirely sure what problem I’ve just created! Can anyone tell me?

    Here’s the original:

    $regex = "(?!<.*?)([\s\'\"\.\x98\x99\x9c\x9d\xCB\x9C\xE2\x84\xA2\xC5\x93\xEF\xBF\xBD\(\[\{])($old_text)([\s\'\"\x98\x99\x9c\x9d\xCB\x9C\xE2\x84\xA2\xC5\x93\xEF\xBF\xBD\?\!\.\,\-\+\]\)\}])(?![^<>]*?>)";

    Here’s the one I’m using:

    $regex = "([\s\>\'\"\.\x98\x99\x9c\x9d\xCB\x9C\xE2\x84\xA2\xC5\x93\xEF\xBF\xBD\(\[\{])($old_text)([\s\<\'\"\x98\x99\x9c\x9d\xCB\x9C\xE2\x84\xA2\xC5\x93\xEF\xBF\xBD\?\!\.\,\-\+\]\)\}])";

Viewing 1 replies (of 1 total)
  • The topic ‘Matching within HTML Tags’ is closed to new replies.