search

Home  >  Q&A  >  body text

javascript - How to use regular expressions to remove the * sign in front of '****abc*vkf****'

abcvkf Only delete the front * sign, and keep the middle and back ones. How should the regular expressions be matched?

PHPzPHPz2775 days ago710

reply all(4)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-19 10:29:04


    Okay, it is always transcoded. Look at the picture. As long as the replace is not global, it will be fine.

    '****abc*vkf****'.replace(/[\*]+/, '')

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-19 10:29:04

    Is this so? Use zero-width assertion http://www.cnblogs.com/deerch...

    var s = '****abc*vkf****',
        res = s.replace(/\**(?=abc)/g,'');

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-19 10:29:04

    var str="abcvkf*";

    var rex=/^*+/ig;

    str.replace(rex,"")

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-19 10:29:04

    reply
    0
  • Cancelreply