0

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

3 Answers 3

1

You can use this regex:

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

Working demo

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

0

RegEx you can use

FunctionName\((.+?),(.+?),

Demo

The last element of the result is your output.

//output
//["FunctionName(11111, 22222,", "11111", " 22222"]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.