Simple regex help php

I have a string Like this:

MyText (1,151)

      

I would like to get with regex only the value inside (), in this case only: 1,151.

I know it's simple, but I'm not very familiar with regex.

Thank!

+2


source to share


2 answers


Almost the same question was asked. There are solutions out there that will work for you;)



+6


source


This will work:



if (preg_match($str, '/\(([^)]*)\)/', $matches))
{
    $content = $matches[1];
}

      

+3


source







All Articles