/    Sign up×
Community /Pin to ProfileBookmark

Hi!
I need hel with regular expression in php
I have a string like this:
uml:nck:rglmn.mm:tipo:2006-08-04;20:1
uml:nck:rglmn.mm:tipo:2006-08-04;25:4
uml:nck:rglmn.mm:tipo:2006-08-04;505:40
I need to take number after last two points (es: 1 or 4 or 40)

this is my code:

[code=php]
preg_match(‘/:([1-9]d+)$/’,$string,$v_match);
$x=$v_match[1];
[/code]

but something is wrong..can you help me?
thanks

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogApr 06.2016 — Perhaps an easier way:
[code=php]
$last_number = array_pop(explode(':', $string));
[/code]

If you really need to do it with a regexp for any reason:
[code=php]
preg_match('/:(d+)$/', $string, $v_match);
[/code]
×

Success!

Help @ojal__ spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...