• Resolved Taufan

    (@taufanxxx)


    Hi,
    Im new on this Regex.
    Please help me. I wanna Replace this:

    <li class="keywords"><img draggable="false" role="img"> #Apple #SoutheastAsia</li>

    To this:

    <li class="keywords"><img draggable="false" role="img"> <a href="">#Apple</a> #SoutheastAsia</li>

    I dont wanna replace other “#Apple” outside the “li” tag.

    I already search on Stackoverflow but the code never works as i expexted.

    Thanks for your help.
    I really appreciated.

    • This topic was modified 4 years, 2 months ago by Taufan.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Marios Alexandrou

    (@marios-alexandrou)

    What find and replace rule have you tried?

    Thread Starter Taufan

    (@taufanxxx)

    I try
    Replace:
    /(<.*?>)(.*Apple?)(<*.*?>)/

    With:

    $1<a href="">#Apple</a>$3

    But I dont know what is that.
    The result is Blank page.

    • This reply was modified 4 years, 2 months ago by Taufan.
    • This reply was modified 4 years, 2 months ago by Jan Dembowski.
    Plugin Author Marios Alexandrou

    (@marios-alexandrou)

    I think you’re probably over complicating things. I would:

    1. Start with a regex rule that just replaces the Apple portion with what you want.
    2. After you have the Apple portion working, add an extra bit at the beginning to match the li tag or the img tag.
    3. I don’t see a reason why you need to match anything after the Apple so you can get rid of 1/3 the rule.

    Finally, if the li tag is the same in all cases, you may not even need regex. Just do a simple match of the li tag including the Apple and replace it with the li tag with the modified Apple.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Replace specific word inside “li”’ is closed to new replies.