title: regex in php using preg_match
body: <p>I am trying to make a php file so it can accept  word for a regex (a+b)(ab+ba)*
  i am using preg_match and so far ive come up with this</p>
  
  <pre><code>    $subject = "a+b";
      $pattern = '(([a]{1}\+[b]{1})?([ab]{1}\+[ba]{1}))';
      preg_match($pattern, $subject, $matches);
      print_r($matches);
  </code></pre>
  
  <p>I am not sure if i completely understand how it works but its been few hours now I am trying to figure out.. how do i make it so it fullfills my condition</p>
  
  <p>I want to match (a+b)(ab+ba)* where the first bracket (a+b) is required and  the * on the second bracket (ab+ba) means that there could be zero or multiple instances of it.
  so it should work like this</p>
  
  <pre><code>   $subject= "(a+b)"
     Match
  
  
     $subject= "(a+b)(ab+ba)"
     Match
  
  
     $subject= "(a+b)(ab+ba)(ab+ba)"
     Match
  
     $subject= "(ab+ba)"
     No Match
  
     $subject= ""
     No Match
  </code></pre>