[英]Extract hashtag from a string till the occurrence of a special character
我的字符串中有標簽。 我可以從#字符開始提取測試。 但是我想在一個特殊字符出現的時候中斷提取。
例:
字符串:這是#first。/ 23k%^標簽
必選摘錄:#first
字符串:這是另一個測試#hashtag /'; 123one
必選摘錄:#hashtag
我對如何在JavaScript中執行此操作進行了大量搜索,但未成功。 請幫助。
您可以使用此匹配項:
str="This is a #first./23k%^ hashtag #foo.#$$ 45";
var m = str.match(/#\w+/g);
//=> ["#first", "#foo"]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.