Closed Thread
Results 1 to 7 of 7

Thread: Replace String

  1. #1
    especta is offline Newbie
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Replace String

    hi
    i load text file from file1.text in memo then
    replace string in memo1 like this
    Code:
    Memo1.Text := StringReplace( Memo1.Text,'number1','Text1',[rfReplaceAll]);
    Memo1.Text := StringReplace( Memo1.Text,'number2','Text1',[rfReplaceAll]);
    Memo1.Text := StringReplace( Memo1.Text,'number3','T111',[rfReplaceAll]);
    i have 50 or more strings to replace
    After finish i have add save in oher file file2.text..
    its work ok
    i must replace all words in file1.text. but when i have no add some string to replace my data is "confuse"

    "how to add auto checking if I dont have add string to replace then auto replace with "unknown" "

    Big Thanks for help

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jun 2007
    Location
    Kosovo
    Posts
    660
    Rep Power
    23

    Re: Replace String

    i dont rely understand what you mean but you could use a timer and then let the timer always call the check function otherwise you could use pos to split the wanted string from the junk text xD
    please explain a little more what you want to do or add a screenshot so we can help you

  4. #3
    especta is offline Newbie
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Re: Replace String

    oki thanks for replay i have attach simple proekt

    i have text file like data base and i need to cange some text with replace string.

    0 ver0 nub123 code 123455 art1: mt:1 grup:2 id32454
    1 cas1 vlez code 321224 art2: mt:1 grup:1 id111235
    2 srt4 nub123 code 233234 art6: mt:1 grup:1 id12347
    3 srt4 nub223 code 222154 art6: mt:1 grup:1 id12345
    and so on

    hire is question when i dont have add 222154 or another number to replace string
    my data is "confuse" like this

    3 srt4 nub223 code 222154 art6: mt:1 grup:2 id1234


    how to add auto checking if I dont have add string to replace (example 222154) then
    auto replace with "unknown"
    3 srt4 nub223 code 222154 "unknown" art6: mt:1 grup:2 id1234

    after replace i create another file and load to grid.

    Big Thanks
    Attached Files Attached Files

  5. #4
    Join Date
    Jun 2007
    Location
    Kosovo
    Posts
    660
    Rep Power
    23

    Re: Replace String

    First off all where does this input come from ? do you use somekind of Listview/Textboxes to get user input or what if like that you could easily test if input is given if not replace it with another string

  6. #5
    especta is offline Newbie
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Re: Replace String

    This input coms from old data base program and i don have source from that database. Connected with new try this file.I must resolve this problem from this text file.

    3 srt4 nub223 code 222154 art6: mt:1 grup:2 id1234

    when if not found string to replace to add "unknown"

    3 srt4 nub223 code 222154 "unknown" art6: mt:1 grup:2 id1234

    thats il all.

    Thanks for replay.

  7. #6
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Replace String

    My hunch is that you're approaching this wrong. Instead of treating it as a single string, treat it as fields. It appears to be space/tab delimited, so break each line into an array of values, and process those.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  8. #7
    especta is offline Newbie
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Re: Replace String

    "I ask you if you have a solution to the problem" send my small example it will more easy to"Continue from there"


    Big Thanks.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problem with string.replace()
    By thatsme in forum JavaScript and CSS
    Replies: 3
    Last Post: 04-27-2011, 08:10 AM
  2. Replies: 11
    Last Post: 03-02-2011, 07:00 PM
  3. [help] C# Replace
    By Darkco in forum C# Programming
    Replies: 7
    Last Post: 12-29-2009, 04:09 PM
  4. Problem in String replace program's output
    By suvojit168 in forum C and C++
    Replies: 2
    Last Post: 10-24-2009, 06:35 AM
  5. adding int to string,creat a file named string..
    By emda321 in forum C and C++
    Replies: 5
    Last Post: 09-10-2009, 07:15 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts