Regex find all string ( include emoji, any language) after specific character

匿名 (未验证) 提交于 2019-12-03 09:02:45

问题:

Regex find all string after specific character.


->



var str = '';
->
[]

function getArr(str) {   var re = /#([a-z0-9_\\pL_]+)/gi;   var arr = [];   // ..  get string after #   str.replace(re, function( a,b ) {     arr.push( b );   });    return arr; }  getArr(str) 

https://regex101.com/r/tJ3jM8/1

回答1:

You can use this negated regex:

/#([^#\s]*)/g 

which means match 0 or more of non-space or non-hash character after # in input.

JS Fiddle

RegEx Demo

Code:



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!