regex - PHP Parse Number From Complicated String -


i looping through array, , have multiple entries returned this.

llll-aaaa-dddd.zzzz-124 xxd98sss-61 fff.sss-ddx-74 

i need way in php parse out last number after last dash on every iteration, can use on function call.

these entries can possibly have other dashes, other numbers, etc... last number have hyphen , number. need complete last number after hyphen.

any regex gurus out there able lend hand?

it's simple regular expression, hardly requiring guru.

preg_match('/-(\d+)$/', $line, $match); $num = $match[1]; 

\d+ matches sequence of digits, , $ matches end of string. parentheses define capture group, , $match[1] contains contents of group.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -