1

I have a string like below

include="3524,3525,3523"][/vc_column_inner][/vc_row_inner][/‌​vc_column][/vc_row][‌​vc_row][vc_column][v‌​c_video link="youtube.com/watch?v=pkBBzH"][/vc_column][/vc_row] 

I just want to extract integer values from string 3524,3525,3523. The number of numeric values can increase I am using the below code

$matches = array();
$content1 = preg_match('/include="(.*)"/',$content1,$imagesmatches);
print_r($matches);

This gets the values and everything else i just want numbers. I know i am using wildcard but i need a expression to just extract numbers from it.

1 Answer 1

2

Based on edited question you can use:

preg_match('/include="\K\d+(?:,\d+)*/', $content, $matches);

print_r($matches[0]);

RegEx Demo

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

2 Comments

include="3524,3525,3523"][/vc_column_inner][/vc_row_inner][/vc_column][/vc_row][vc_row][vc_column][vc_video link="youtube.com/watch?v=pkBBzH"][/vc_column][/vc_row] from this strng i want to get only number like 3524,3525 nut the number of numbers in the string can increase i am using this expression preg_match('/include="(/[^\d]/)"/',$content1,$imagesmatches); but it gets everything along with number... Any suggestion
Thanks ... I have made the edit ... your help is much appretiated

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.