Editing a post in Character Replacing. Is this possible in PHP?

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

    Editing a post in Character Replacing. Is this possible in PHP?

    I want to be able to strip any character that is does not appear in
    the following list from a text string:

    $LegalChars="\" !#$%&'()*+,-.\\/0123456789:;=?@ ABCDEFGHIJKLMNO PQRSTUVWXYZ[]^_`abcdefghijkl mnopqrstuvwxyz{ |}~";

    And conververt the following:
    £ to £
    € to €
    ‘ to '
    ' to '
    " to "
    " to "
    • to •

    So, if the input string was:

    $Input = "Andrés says "...the € is very useful"";

    The out at is generated is:

    $Output = "Andres says "...the € is very useful"";

    (I've marked the changes in red above)

    Could anyone write me a little function that can do this?
    Many thanks
  • Gary L. Burnore

    #2
    Re: Editing a post in Character Replacing. Is this possible in PHP?

    On 23 Nov 2004 14:00:08 -0800, Phantom.Mask@ph otoshot.com (Janey)
    wrote:
    [color=blue]
    >I want to be able to strip any character that is does not appear in
    >the following list from a text string:
    >
    >$LegalChars="\ "!#$%&'()*+ ,-.\\/0123456789:;=?@ ABCDEFGHIJKLMNO PQRSTUVWXYZ[]^_`abcdefghijkl mnopqrstuvwxyz{ |}~";
    >
    >And conververt the following:
    > £ to £
    > € to €
    > ‘ to '
    > ' to '
    > " to "
    > " to "
    > • to •
    >
    >So, if the input string was:
    >
    >$Input = "Andrés says "...the € is very useful"";
    >
    >The out at is generated is:
    >
    >$Output = "Andres says "...the € is very useful"";
    >
    >(I've marked the changes in red above)
    >
    >Could anyone write me a little function that can do this?[/color]

    Write you? Hah.

    check out str_replace and write it yourself.
    [color=blue]
    >Many thanks[/color]

    --
    gburnore@databa six dot com
    ---------------------------------------------------------------------------
    How you look depends on where you go.
    ---------------------------------------------------------------------------
    Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
    | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
    DataBasix | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
    | ÝÛ³ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ÝÛ³
    Black Helicopter Repair Svcs Division | Official Proof of Purchase
    =============== =============== =============== =============== ===============
    Want one? GET one! http://signup.databasix.com
    =============== =============== =============== =============== ===============

    Comment

    • Alan Little

      #3
      Re: Editing a post in Character Replacing. Is this possible in PHP?

      Carved in mystic runes upon the very living rock, the last words of
      Janey of comp.lang.php make plain:
      [color=blue]
      > (I've marked the changes in red above)[/color]

      In a plain text post?
      [color=blue]
      > Could anyone write me a little function that can do this?[/color]

      The PHP developers have already written you a little function that can do
      this.

      Try http://www.php.net/preg_replace for the stripping and
      http://www.php.net/str_replace for the replacing.

      --
      Alan Little
      Phorm PHP Form Processor

      Comment

      Working...