Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Search and replace

Search and replace

Search and replace

Is there a function or does someone have one written which searches for a substring within a string and replaces it with another?  
e.g.  MyString = "MyLastName, Tim",
      MySearchString = ","
      MyReplaceStr = " "  

The result being "MyLastName  Tim"

RE: Search and replace


I'm not sure of the online version where informix introduced the replace function -probably 7.x.  I'm sure it wasn't there in 5.x.

From Ron Flannery's, The Informi Handbook:

"The REPLACE function replaces characters within a string with different characters.  The syntax for this function is:

REPLACE(input string, old_string, new_string where:

input_string is the string you want to replace.

old_string are the characters with input_string that   you  want to replace

new_string is the string with which you want to replace old_string"


Here's a nonsensical example you can execute from dbaccess/isql:

create temp table names (
  mystring char (80)
insert into names values ("MyLastName, Tim");
select mystring, replace(mystring, ",", "") from names;
drop table names;

This is probably what you want.  As an old Informix 4GL programmer, I developed a replace string function, but, obviously, it's useless unless you're using 4GL.  It's yours for the asking.



Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close