在php中用正则表达式查找字符串

I am new to regex and therefore i gone through php manual for regex and tried the below:

i have a string like this:

c-1

c-10

c-100 and so on upto c-unlimited

now i want to confirm that the string coming is a valid string which starts with c- and after c- it only contains numbers..

to get this work i have used preg_match

$slug='c-12';

if(preg_match("/\[c-(.*?)]/",$slug,$result)){ echo "TRUE";}
else{ echo "FALSE"; }

also this:

$pattern = '/^c-/';
if(preg_match($pattern, substr($slug,2), $matches, PREG_OFFSET_CAPTURE){ echo "TRUE";}
else{ echo "FALSE"; }

and also this:

$pattern = '/^c-/';
if(preg_match($pattern, $slug, $matches, PREG_OFFSET_CAPTURE, 3){ echo "TRUE";}
else{ echo "FALSE"; }

and one more thing i also wanted to to validate the string from end. like below:

 $slug="my-string-content-123";

here i wanted to validate that the string contains the number at end after -

example 123

but i am not able to get it work... and i am sorry for my bad english..

any help or suggesstion would be a great help.. thanks in advance..

For common (not just c-) case:

$slug="my-string-content-123";
if(preg_match('/([^0-9]+)-([0-9]+)$/', $slug, $matches))
{
   //prefix is in $matches[1];
   //the number is in $matches[2];
}

Try this:

preg_match("/^c-\d+$/",$slug,$result);

^c- = start with c-

\d+ = 1 or more digits

$ = end of string