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
asked Aug 8, 2014 at 2:03
Mixim
9722 gold badges12 silver badges38 bronze badges
3 Answers 3
answered Aug 8, 2014 at 2:12
Federico Piazza
31.2k15 gold badges91 silver badges133 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
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.
answered Aug 8, 2014 at 2:13
Barmar
789k57 gold badges555 silver badges669 bronze badges
Comments
RegEx you can use
FunctionName\((.+?),(.+?),
The last element of the result is your output.
//output
//["FunctionName(11111, 22222,", "11111", " 22222"]
answered Aug 8, 2014 at 2:24
Harpreet Singh
2,67123 silver badges31 bronze badges
Comments
lang-js