remove / replace unwanted prefixed info from `class` name

后端 未结 2 1785
滥情空心
滥情空心 2021-01-25 18:08

I am getting style from backend. it has unwanted prefix with it. i would replace the same without the prefix. what would be the correct way?

here is what wh

相关标签:
2条回答
  • 2021-01-25 18:54

    It seems the prefix is hexadecimal, so this will do the job:

    str.replace(/^[A-F0-9]+\s+/gm, '')
    
    0 讨论(0)
  • 2021-01-25 19:01

    Here's a solution :

    $('style').html(function(_,h){
      return h.replace(/^\w+ (\.\w+)/gm,'$1');
    });
    

    This removes any string at the start of a line and before a class selector in any <style> element.

    Demonstration

    0 讨论(0)
提交回复
热议问题