Given the following string how can I match the entire number at the end of it?
$string = "Conacu P PPL Europe/Bucharest 680979";
I have to tell that the lenght of the string is not constant.
My language of choice is PHP.
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could use a regex with
preg_match, like this :And you’ll get :
And here is some information:
#at the beginning and the end of the regex are the delimiters — they don’t mean anything : they just indicate the beginning and end of the regex ; and you could use whatever character you want (people often use/)()means you want to capture what is between thempreg_match, the array given as third parameter will contain those captured data()\dmeans “a number”+means one or more timeSo :
For more information, you can take a look at PCRE Patterns and
Pattern Syntax.