Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Marios Alexandrou

    (@marios-alexandrou)

    Yes this can be done. It’s actually a common use for the plugin. You need to use a regex rule where the find is something like [tag](.*)?[/tag].

    Sometimes you need a regular expression that is a little “smarter”, but I’ve used the above in many places.

    Thread Starter Lemonsprig

    (@lemonsprig)

    Hi Marios,

    thanks for letting me know it can be done. I am struggling however to get it to work, and now I am getting a blank page no matter what page I visit (even ones without the tags I am looking for). From the help I understand that this is due to incorrect regex formatting. Can you help please

    this is what I have

    /[<div class=”ERIngredients”>](.*)?[/<div class=”ERNutrition”></div>]/

    So effectively I want to remove everything between

    <div class=”ERIngredients”> and <div class=”ERNutrition”></div> ideally I would like to remove the actual tags themselves but I don’t know if that is possible.

    Thanks

    Ian

    Plugin Author Marios Alexandrou

    (@marios-alexandrou)

    Are you including the [ ] because I had them in my example or because they exist in your code? If the former, remove them.

    Also, with regular expressions you need to have back-slash in front of every forward-slash. So </div> should actually be <\/div>. This is a requirement of the regex syntax. Sorry I should’ve been more explicit in my initial explanation.

    So your rule, based on what you provided, should be:

    /<div class=”ERIngredients”>(.*)?<div class=”ERNutrition”><\/div>/

    On my test site the above at least doesn’t result in a blank screen.

    This will be replaced with whatever you have in the replace box. If blank, everything including the tags will be removed. Note that it looks like you’ll be left with an extra closing div tag based on what you provided.

    Thread Starter Lemonsprig

    (@lemonsprig)

    Thanks Marios,

    That did the trick. I did include the [] from your initial post, but tried it both ways as I wasn’t sure. I am still trying to wrap my head around regular expressions, it’s a bit confusing and some guides make it just look like a string of gibberish.

    In any event, I have now achieved the desired effect. I think to achieve what I really want however will require an upgrade to the pro version. But I will raise a separate question for that so as not to confuse this one for others who may have a similar issue.

    Thanks Again

    Ian

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Replace everything between two points’ is closed to new replies.