original_string: protected function prepareRegexRule($value)
      {
          $escape = ['$' => '\$', '?' => '\?', '.' => '\.', '*' => '.*'];
          foreach ($escape as $search => $replace) {
              $value = str_replace($search, $replace, $value);
          }
          if (mb_strlen($value) > 2 && mb_substr($value, -2) == '\$') {
              $value = substr($value, 0, -2) . '$';
          }
          if (mb_strrpos($value, '/') == (mb_strlen($value) - 1)
              || mb_strrpos($value, '=') == (mb_strlen($value) - 1)
              || mb_strrpos($value, '?') == (mb_strlen($value) - 1)
          ) {
              $value .= '.*';
          }
  
  	    if (substr($value, 0, 2) != '.*') {
  		    $value = '^' . $value;
  	    }
          return $value;
      }
code: protected function prepareRegexRule($value)
      {
          $escape = ['$' => '\$', '?' => '\?', '.' => '\.', '*' => '.*'];
          foreach ($escape as $search => $replace) {
              $value = str_replace($search, $replace, $value);
          }
          if (mb_strlen($value) > 2 && mb_substr($value, -2) == '\$') {
              $value = substr($value, 0, -2) . '$';
          }
          if (mb_strrpos($value, '/') == (mb_strlen($value) - 1)
              || mb_strrpos($value, '=') == (mb_strlen($value) - 1)
              || mb_strrpos($value, '?') == (mb_strlen($value) - 1)
          ) {
              $value .= '.*';
          }
  
  	    if (substr($value, 0, 2) != '.*') {
  		    $value = '^' . $value;
  	    }
          return $value;
      }
code_tokens: protected function prepareRegexRule ( $ value ) { $ escape = [ '$' => '\$' , '?' => '\?' , '.' => '\.' , '*' => '.*' ] ; foreach ( $ escape as $ search => $ replace ) { $ value = str_replace ( $ search , $ replace , $ value ) ; } if ( mb_strlen ( $ value ) > 2 && mb_substr ( $ value , - 2 ) == '\$' ) { $ value = substr ( $ value , 0 , - 2 ) . '$' ; } if ( mb_strrpos ( $ value , '/' ) == ( mb_strlen ( $ value ) - 1 ) || mb_strrpos ( $ value , '=' ) == ( mb_strlen ( $ value ) - 1 ) || mb_strrpos ( $ value , '?' ) == ( mb_strlen ( $ value ) - 1 ) ) { $ value .= '.*' ; } if ( substr ( $ value , 0 , 2 ) != '.*' ) { $ value = '^' . $ value ; } return $ value ; }
docstring: Convert robots.txt rules to php regex
  
  @param  string $value
  @return string
docstring_tokens: Convert robots . txt rules to php regex