JavaScript 正则表达式匹配

标签 javascript regex

当我使用 AJAX 查询服务器时,它返回字符串值。该字符串具有预定义格式,例如:

1|#||4|2352|updatePanel|updatePanelID

<table style="width:100%">
<tr>
<td>
</td>
</tr>
</table>

<table id="requiredTable"/>
<tbody>

<tr>
<th>column1</th>
<th>column2</th>
</tr>

<tr style="cursor:pointer" onclick="FunctionName(11111, 22222, 3);">
<td>trColumn1Info</td>
<td>trColumn2Info</td>
</tr>

some other information

我想通过正则表达式获取FunctionName的第二个参数值。我尝试使用下一个正则表达式,但它总是返回 null:

var forTest = ajaxResultStr.match(/FunctionName\((\S*)\)/g);
alert(forTest);

谁能告诉我,我的模式有什么问题吗? 提前致谢

最佳答案

您可以使用此正则表达式:

FunctionName.*?,\s*(\w+)

<强> Working demo

enter image description here

关于JavaScript 正则表达式匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25195053/

相关文章:

javascript - 带有 iOS 透明状态栏的 JQM 固定 header

javascript - onmouseover 更改 img 不起作用

javascript - While 循环与 requestAnimationFrame

c# - 如何提取通用/相似代码块以在 Visual Studio C# 中运行

javascript - 使用jquery获取<tag>的内容

javascript - KineticJS:如何从 Canvas 初始化图像?

Javascript 相当于 Ruby Time.parse

java - 用于排除选项集的正则表达式

php - 正则表达式不起作用

php - 简单的 preg_replace() 我无法工作(我对正则表达式很糟糕)