Coder Social home page Coder Social logo

coding's People

Contributors

ynchuan avatar

Watchers

 avatar  avatar

Forkers

qq85609655

coding's Issues

正则表达式实例记录

需求: var str="<a href='@sfzh'>129903232</a><a href='@sfzfh'>49903232</a>"
将字符串中的@***替换为其后面的数字

解决:str.replace(/<a href='(.+?)'>(.*?)<\/a>/g,"<a href='$2'>$2<\/a>")
结果:"<a href='129903232'>129903232</a><a href='49903232'>49903232</a>"

说明:/<a href='(.+?)'>(._?)</a>/g;将替换项做成捕获组(加括号的部分),同时注意在_|+添加?实现非贪婪匹配,最后采用$2完成捕获组项的替换

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.