javascript - 正则表达式提取模板标签 <%= 和 %>
问题描述
我需要提取 <%= 和 %> 之间的所有内容,如下所示:
<%=你好%> <%=你好%> <%=你好%> <%=你好.bye%> <%=hello_you.bye_you%>
我有这段代码 - 我想捕获标签之间的所有内容,应该忽略空格。
["你好","你好","你好","hello.bye","hello_you.bye_you"]
我有这个尝试,有人可以改进正确的正则表达式以满足要求吗?
var found = [], // an array to collect the strings that are found
rxp = /<%=([^}}]+)%>/g,
curMatch;
while (curMatch = rxp.exec(str)) {
found.push(curMatch[1]);
}
解决方案
推荐阅读
- google-cloud-platform - 无法删除集群,Peering 不存在
- azure - 使用 Microsoft Speech API 对多种声音进行语音到文本识别?
- python - AttributeError: _nanosecond 在更新事务中的日期时间时
- javascript - 在复杂的 v-for 循环中预选 Vue 组件中的无线电输入
- macros - SAS 宏代码生成特定年份的平均销售额
- sql-server - Azure 数据工厂中的 CDC 支持
- mongodb - 在 mongo 中更改数据类型和更新值
- angular - Angular 6以反应形式动态创建单选按钮和复选框
- oracle - DECS 活动不会开始
- python - keras / tensorflow层的“形状”和权重何时何地确定和存储?