Loading ...
Sorry, an error occurred while loading the content.

Preg replace ??

Expand Messages
  • Sarah Fox
    Hi, I m familiar with the PHP version of preg_replace, but is this also a perl function aswell ? I ve been to perldoc.perl.org (using the google search), &
    Message 1 of 4 , Apr 24, 2010
    • 0 Attachment
      Hi,

      I'm familiar with the PHP version of preg_replace, but is this also a perl function aswell ?

      I've been to perldoc.perl.org (using the google search), & looked for "preg_replace", "preg replace", and even just "preg"

      but no results...

      I was sure preg was a standard perl function - is it ?


      Basically, I want to get a string, Look at the beginning of a line & see if it has a word (or not)..

      also with the /i flag (Doesn't matter if its UPPER or lower case) - & if the word exists, remove it & any preceeding spaces....


      I'm sure this is a standard perl function.
    • Charles K. Clarkson
      ... Yes. It is called substitution and is similar, but easier to write than preg_replace. preg stands for perl regular expressions. Since you are already in
      Message 2 of 4 , Apr 24, 2010
      • 0 Attachment
        Sarah Fox wrote:

        : I'm familiar with the PHP version of preg_replace, but is this also
        : a perl function aswell ?

        Yes. It is called substitution and is similar, but easier to write than
        preg_replace. "preg" stands for perl regular expressions. Since you are
        already in Perl, it would be redundant to include the preg prefix on
        Perl function names.


        : I'm sure this is a standard perl function.

        s/// is described in the perlop manpage under the Regexp Quote-Like
        Operators section.


        HTH,

        Charles Clarkson
        --
        Mobile Home Investor
        Free Market Advocate
        Programmer

        I'm not really a smart person. I just play one on the Internet.

        Stephenville, TX
        http://www.clarksonenergyhomes.com/wordpress/about/
        http://twitter.com/CharlesClarkson
        +1 (254) 968-8328
      • Shlomi Fish
        ... Also see the links at: http://perl-begin.org/topics/regular-expressions/ One should note that Perl has first-order syntax for regular expressions instead
        Message 3 of 4 , Apr 25, 2010
        • 0 Attachment
          On Sunday 25 Apr 2010 08:27:33 Charles K. Clarkson wrote:
          > Sarah Fox wrote:
          > : I'm familiar with the PHP version of preg_replace, but is this also
          > : a perl function aswell ?
          >
          > Yes. It is called substitution and is similar, but easier to write than
          > preg_replace. "preg" stands for perl regular expressions. Since you are
          > already in Perl, it would be redundant to include the preg prefix on
          > Perl function names.
          >
          > : I'm sure this is a standard perl function.
          >
          > s/// is described in the perlop manpage under the Regexp Quote-Like
          > Operators section.
          >

          Also see the links at:

          http://perl-begin.org/topics/regular-expressions/

          One should note that Perl has first-order syntax for regular expressions
          instead of PHP's regular-expressions-inside-delimiters-inside-strings. So you
          need to do less double backslashes (e.g: "\\(") and the syntax is more
          consistent.

          >
          > HTH,
          >
          > Charles Clarkson
          > --
          > Mobile Home Investor
          > Free Market Advocate
          > Programmer
          >
          > I'm not really a smart person. I just play one on the Internet.
          >

          :-)

          I once said that "I am not an actor. I just play one on T.V.":

          http://www.shlomifish.org/humour.html#not_an_actor

          Regards,

          Shlomi Fish

          --
          -----------------------------------------------------------------
          Shlomi Fish http://www.shlomifish.org/
          "Humanity" - Parody of Modern Life - http://shlom.in/humanity

          Deletionists delete Wikipedia articles that they consider lame.
          Chuck Norris deletes deletionists whom he considers lame.

          Please reply to list if it's a mailing list post - http://shlom.in/reply .
        • Sarah Fox
          ... From: Charles K. Clarkson ... s/// is described in the perlop manpage under the Regexp Quote-Like Operators section.
          Message 4 of 4 , Apr 25, 2010
          • 0 Attachment
            ----- Original Message ----
            From: Charles K. Clarkson <cclarkson@...>
            >>: I'm sure this is a standard perl function.

            s/// is described in the perlop manpage under the Regexp Quote-Like
            Operators section.
            <

            Ah, thank you.. - found it.
          Your message has been successfully submitted and would be delivered to recipients shortly.