Q: Php preg_match_all, wordpress function I have found this code on internet...i'm really don't know about php...
can someone tech me,pleasee..
<?php
function catch_that_image() {
  global $post, $posts;
  $first_img = '';
  ob_start();
  ob_end_clean();
  $output = preg_match_all('<img.+src=[\'"]([^\'"]+)[\'"].*>', $post->post_content, $matches);
  $first_img = $matches [1] [0];

  if(empty($first_img)){ //Defines a default image
    $first_img = "/images/default.jpg";
  }
  return $first_img;
}
?>

How to replace <img.+src=[\'"]([^\'"]+)[\'"].*>
if i want take word after "=" and before "]" 
with this text:
[image name=ubuntustudio-tribal-54] 
or
[image name=office-tool]
or 
[image name=car] 
or 
[image name=158]

i  want the output TAKE "a-z or symbol or number" AFTER THIS "=" and BEFORE THIS "]" 
Thanks

A: The code you found on the internet is kind of irrelevant. In order to achieve what you want you need something like this:
$str = "[image name=ubuntustudio-tribal-54] ";
$pat = "~\[image name=([^\]]+)~i";
preg_match($pat, $str, $matches);
$name = $matches[1];

After that $name would be bound to ubuntustudio-tribal-54.
See the docs for more details regarding PHP's preg_match.
See also, this great source of info about Regular Expressions in general.
