Sign in to follow this  
Followers 0
Gauss

Extract Grouped Digits from a String?

4 posts in this topic

This is probably a silly Question but how can i get the digits extracted from a string and store it in an array of numbers

For example:

$str = 'Mark scored 95 out of 100 in the final test'

Expected Result:95,100

I tried this: $num = StringRegExp($str, '(d+)', 2) but I'm getting the result as 95,95

Can someone please help me quickly?

Share this post


Link to post
Share on other sites



Thanks! It Works! :)

Share this post


Link to post
Share on other sites

1 more small question

I sometimes get garbage value between these 2 number $str = 'Mark scored 95 out 08 of 100 in the final test'

How to get the first and the last group of numbers?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0