char replacement

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

    char replacement

    Hi,
    I have a table with a field that contains a file path(www/docs/.../.../...)
    Some of the path contain this characters 'é' or 'è'.
    How can i do an update on this table to replace only the characters 'é' or
    'è' by a 'e'.
    Thanks for your ideas
    VooDoo


  • Ewoud Dronkert

    #2
    Re: char replacement

    VooDoo wrote:[color=blue]
    > How can i do an update on this table to replace only the characters
    > 'é' or 'è' by a 'e'.[/color]

    In PHP:

    $subject = 'somé linè';
    $search = 'éè';
    $replace = 'ee';
    $updated = strtr($subject, $search, $replace);

    or

    $subject = 'somé linè';
    $search = array('é', 'è');
    $replace = 'e';
    $updated = str_replace($se arch, $replace, $subject);

    But I guess you need a SQL query ("table with a field"). Better ask in
    comp.databases. mysql or have a look at
    http://dev.mysql.com/doc/refman/4.1/...functions.html It might be

    UPDATE t1 set f1 = REPLACE(REPLACE (f1, 'è', 'e'), 'é', 'e')

    --
    E. Dronkert

    Comment

    • VooDoo

      #3
      Re: char replacement

      It works! thanks a lot for your answer!
      cya
      VooDoo
      "Ewoud Dronkert" <firstname@last name.net.invali d> a écrit dans le message de
      news: sakjm11q842meqe e2opin3krs6lrb5 bn1o@4ax.com...[color=blue]
      > VooDoo wrote:[color=green]
      >> How can i do an update on this table to replace only the characters
      >> 'é' or 'è' by a 'e'.[/color]
      >
      > In PHP:
      >
      > $subject = 'somé linè';
      > $search = 'éè';
      > $replace = 'ee';
      > $updated = strtr($subject, $search, $replace);
      >
      > or
      >
      > $subject = 'somé linè';
      > $search = array('é', 'è');
      > $replace = 'e';
      > $updated = str_replace($se arch, $replace, $subject);
      >
      > But I guess you need a SQL query ("table with a field"). Better ask in
      > comp.databases. mysql or have a look at
      > http://dev.mysql.com/doc/refman/4.1/...functions.html It might be
      >
      > UPDATE t1 set f1 = REPLACE(REPLACE (f1, 'è', 'e'), 'é', 'e')
      >
      > --
      > E. Dronkert[/color]


      Comment

      Working...