WordPress.org

Forums

Code problem (8 posts)

  1. Jaxia
    Member
    Posted 10 years ago #

    Anyone have a moment to help with a coding problem? I'm trying to make the acronym replacer case sensitive and when I follow the included instructions, I get an error that tells me I have an unexpected $ on line 187, but line 187 doesn't have a $. I only made two changes - I added the /// (I tried 2 and 3, neither fixed the problem) to this line:

    /// $text = preg_replace("|(?!<[^<>]*?)(?<![?./&])\b$acronym\b(?!:)(?![^<>]*?>)|imsU","$acronym" , $text);

    and removed the slashes from these lines:

    $text = preg_replace("|([^./]\b)$acronym(\b[^:])|msU" , "$1$acronym$2" , $text);
    $text = preg_replace("|(<[A-Za-z]* [^>]*)$acronym([^<]*>)|msU" , "$1$acronym$2" , $text);

    Please help! With sugar on top?

  2. ColdForged
    Member
    Posted 10 years ago #

    Some background would be helpful:

    1. Which acronym replacer?
    2. Which instructions?

  3. Jaxia
    Member
    Posted 10 years ago #

    My apologies:

    Joel Bennett's, version 2.8

    Instructions say: "Pick whichever you want, and make SURE there is only one that isn't preceded by slashes: // "

    Does that help?

  4. moshu
    Member
    Posted 10 years ago #

  5. Jaxia
    Member
    Posted 10 years ago #

  6. ColdForged
    Member
    Posted 10 years ago #

    Odd one, Jaxia. Here's the fix: Instead of inserting slashes in front of that "OLD DEFAULT" version, do it like so:

    /* $text = preg_replace("|(?!<[^<>]*?)(?<![?./&])b$acronymb(?!:)(?![^<>]*?>)|imsU","<acronym title=\"$description\">$acronym</acronym>" , $text);*/

    Or, get rid of that line completely. See if that helps.

  7. Jaxia
    Member
    Posted 10 years ago #

    ColdForged - Ack. Now I feel silly. I just deleted the lines and it worked. Sometimes the simple answer is best. I really appreciate it!

    (But I thought lines with // in front would be ignored, too? No?)

  8. ColdForged
    Member
    Posted 10 years ago #

    I'm a bit confused myself why the commenting out of that line with the single-line comment syntax causes that problem.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.