I don't know how to do this pattern!!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KT1990
    New Member
    • Jun 2010
    • 1

    I don't know how to do this pattern!!!

    The role name occurs immediately after the first ‘ a ‘

    E.g.
    'An Astounding Reflection of a Lumberjack And a ...'

    Output shold be

    Lumberjack
    Boy
    ...
    ...
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Read up on regular expressions, please.

    Code:
    php > $string = 'An Astounding Reflection of a Lumberjack And a';
    php > preg_match('#a (.*?) #', $string, $matches);
    php > var_dump($matches);
    array(2) {
      [0]=>
      string(13) "a Lumberjack "
      [1]=>
      string(10) "Lumberjack"
    }
    Mark.

    Comment

    Working...