When I use AJAX query to server, it return me string value. This string have predefined format like:
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
I want to get second arguments value of FunctionName by regular expression. I tryed to use next regexp, but it always return null:
var forTest = ajaxResultStr.match(/FunctionName\((\S*)\)/g);
alert(forTest);
Can anybody tell me, whats wrong in my pattern? Thanks in advance
Your regexp only matches when there are no spaces between (
and )
. Since there are spaces between the arguments, it doesn't match. Try:
var forTest = ajaxResultStr.match(/FunctionName\([^,]+,\s*([^,]+),.*\)/);
forTest[1]
will contain the second argument.
RegEx you can use
FunctionName\((.+?),(.+?),
The last element of the result is your output.
//output
//["FunctionName(11111, 22222,", "11111", " 22222"]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.