【问题标题】:regular expression pattern [#[#hello]#] match in javascript [duplicate]javascript中的正则表达式模式[#[#hello]#]匹配[重复]
【发布时间】:2017-12-27 11:04:22
【问题描述】:
var str1 = "hello <span contenteditable="false" class="underlineText hashtags hello">hello<span style="display:none;"> [#[#hello]#] [#[#hi]#]  [#[#welcome]#]</span></span>"

var arr = textToPost.match(/#^[a-zA-Z0-9]/g)

我想提取与此模式匹配的字符串 [#[# * ]#] 。

【问题讨论】:

  • 那么,您想提取hellohiwelcome - 对吗?

标签: javascript regex string design-patterns match


【解决方案1】:

试试这个正则表达式,它对我有用

var reg = /\[[#[a-zA-Z0-9]+]#]/ig;

var str1 = "hello hello [#[#hello]#] [#[#hi]#] [#[#welcome]#]";
var reg = /\[[#[a-zA-Z0-9]+]#]/ig;
var arr = str1.match(reg);
console.log(arr)

【讨论】:

  • 工作正常,非常感谢:)。你让我的一天变得轻松
  • 如果您觉得有帮助,欢迎您投票
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多