regular expression help needed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • monomaniac21

    regular expression help needed

    hi

    how can i take a string and delete everything up to and including the
    first occurrence of a forward slash (/)? please help.

    regards

    marc

  • ZeldorBlat

    #2
    Re: regular expression help needed

    On Jun 21, 10:14 am, monomaniac21 <mcyi2...@googl email.comwrote:
    hi
    >
    how can i take a string and delete everything up to and including the
    first occurrence of a forward slash (/)? please help.
    >
    regards
    >
    marc
    You don't need a regular expression to do that:

    $str = 'some/string';
    $str = substr($str, strpos($str, '/')+1);

    Comment

    • Michael Fesser

      #3
      Re: regular expression help needed

      ..oO(monomaniac 21)
      >how can i take a string and delete everything up to and including the
      >first occurrence of a forward slash (/)? please help.
      Try

      $text = preg_replace('# ^.*?/#', '', $text);

      You could also do it with strpos() and substr_replace( ).

      Micha

      Comment

      Working...