作者:临沂李晓楠 | 来源:互联网 | 2023-05-16 22:05
Ineedtoextracteverythingbetweena#andaspaceoranypunctationcharacter(.,;:_-)Thisisw
I need to extract everything between a #
and a space or any punctation character ( .,;:_-
) This is what I have so far.
我需要在#和空格或任何标点符号之间提取所有内容(。,;:_-)这是我到目前为止所拥有的。
var str = "#hello. foo bar"
var filter:RegExp = /#(.*?)(!.,?;:_-)/g;
var matches:Object = filter.exec(str);
if(matches != null){
trace("Found: "+matches[1])
} else {
trace("nothing found")
}
It only works if the word is #hello! - I guess this part (!.,?;:_-)
is wrong?
它只适用于单词#hello! - 我猜这部分(!。,?;:_-)是错的?
2 个解决方案