Results 1 to 2 of 2

Thread: Replacing strings in MSDOS

  1. #1
    Join Date
    Feb 2011
    Posts
    1

    Replacing strings in MSDOS

    Hi,

    I'm having difficulty to replace strings in a twxt file, so I was wondering if anyone could help.

    In file text.txt I need to replace string that starts with "myString……..." with string "yourStringABC". So the example of text.txt is:

    Text.txt
    ---------------------

    My name is Diana
    My age is 19
    My occupation is student
    I have myStringxxxxxxxx
    Please help to replace this string

    ----------------------------

    After replacement the file should look like:

    Text.txt
    ---------------------

    My name is Diana
    My age is 19
    My occupation is student
    I have yourStringABC
    Please help to replace this string

    ----------------------------
    In this original file xxxxxxx can be anything but I know that it does not contain any spaces.

    Anyone done this before?
    Thanks,

  2. #2
    Join Date
    May 2008
    Posts
    1,020

    Re: Replacing strings in MSDOS

    The best way to deal with is to look for some ready to use batch file. This files are already made to play with dos string manipulation. I have a solution for the same. For the replacement of the substring with an different string you will need to use the feature of string substitution. The script for the same will be somewhat like this :
    Code:
    1. set str=xxxxx cat in teh hat
    2. echo.%str%
    3. set str=%str:xxxxxx=yyyyyy%
    4. echo.%str%
    Follow the above procedure for your support.

Similar Threads

  1. Files and strings in C
    By An1990 in forum Software Development
    Replies: 2
    Last Post: 10-05-2012, 10:11 PM
  2. Not able to run MSDos Gwbasic programs on XP Pro OS
    By Giaan in forum Windows Software
    Replies: 10
    Last Post: 22-11-2011, 11:35 AM
  3. Strings in JavaFX
    By Messenger in forum Software Development
    Replies: 3
    Last Post: 16-07-2010, 04:57 PM
  4. Windows Vista Error: Invalid MSDOS function - Solution
    By Praetor in forum Tips & Tweaks
    Replies: 0
    Last Post: 11-02-2009, 02:15 PM
  5. Replies: 3
    Last Post: 22-10-2008, 07:12 PM

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
  •  
Page generated in 1,714,175,387.79798 seconds with 17 queries