c How to replace the contents of a specified line

Updated on technology 2024-03-14
13 answers
  1. Anonymous users2024-02-06

    I'm going to write about it roughly.

    string strcontent = ;

    if (!Represents the file directory.

    return;

    streamreader sr = new streamreader(filepath);

    strcontent = ;Get the file contents.

    For getting a line in a file, this depends on your situation, because if the content in the file is in the texter.

    In the case of word wrapping, the string is actually obtained.

    There are no line breaks in the middle.

    , so it's hard to be sure if a line you're talking about is a line you see in the texter or if it has a line break to start a new line.

    If there is a line break as the start of a new line, it is roughly as follows.

    strcontent indicates the content of the file, and irow indicates a row to be queried.

    string strarray="\\

    string strdes=strarray[irow-1];strdes represents the content of the target line.

    newstr indicates the content after replacement, and oldstr indicates the content before replacement.

    newstr);

    Do the rest yourself.

    If it's the line number after word wrap that you see in the texter, then you can't determine the "line".

  2. Anonymous users2024-02-05

    1. It can be implemented using the replace method of the string object.

    2. VS2005 C Example:

    using system;

    using ;

    using ;

    static void main(string args)string ss = "hello world.";

    ss="hello","hi");;

  3. Anonymous users2024-02-04

    The rest is the same as them.

    It should look like this, conn="","");

  4. Anonymous users2024-02-03

    There are two methods in the string class, substring and indexof, which you can just look at and replace them.

  5. Anonymous users2024-02-02

    Solution 1: Make use of the string) method. First of all, the original content that needs to be replaced (i.e., yx[*) is obtained by the method, string, and then replaced.

    Solution 2: First, split into string arrays, then replace them one by one, and finally iterate and combine the replaced string arrays (through certain rules).

  6. Anonymous users2024-02-01

    Reference unit.

    using ;

    Example. str = , "yx\[(d+),d+)\", m =>);The result is {yx[1,1]|(I was replaced&yx[22,4])|yx[24,16]}

  7. Anonymous users2024-01-31

    Copy the precedent of the specified line to the temporary file, insert the specified line, add the following part, and finally overwrite the existing file.

  8. Anonymous users2024-01-30

    If you simply delete the specified string"Haha"

    Directly press the method of replace (.)"Haha"If you delete the specified row, you need to:

    streamreader reader = new streamreader("c:/");

    int index = 0;

    while(true)

    index++;

  9. Anonymous users2024-01-29

    Just call a wrapper function replace, which has two overloads;

    replace(char oldchar, char newchar)

    Replace all occurrences of the specified Unicode character in this instance with the other specified Unicode characters.

    replace(string oldvalue, string newvalue)

    Replace all occurrences of the specified string in this instance with the other specified strings.

    The first parameter is the replaced string, and the second parameter is the replaced parameter.

    e.g. var politicallycorrect ="men", "people");Replaced all men with people.

  10. Anonymous users2024-01-28

    string str="abcdefghijkfsfsdfsd";

    str="abc","123");

    This replaces all the ABCs in the STR with 123.

  11. Anonymous users2024-01-27

    Simple example of string to replace. Complex with regular expressions.

  12. Anonymous users2024-01-26

    The string object has a replace method that replaces characters.

  13. Anonymous users2024-01-25

    Backup: Method.

    Replace: Read all text into a string.

    Regular expression substitution, try it yourself, and then ask the file back if the regex of the specific replacement is wrong.

Related questions
9 answers2024-03-14

I think it works, I did it once when I first started working, and I don't remember it very well, but you can try it with the seek function, locate it first, read it later, and I remember when I was doing this, I read the book The C Programmer, which is about 234 pages.

11 answers2024-03-14

It's textbox, right? textbook?

double somedouble; >>>More

14 answers2024-03-14

protected void page_load(object sender, eventargs e)

Get the file path. >>>More

8 answers2024-03-14

Looks like you're going to get the dragon stuck off the tower. I also encountered your problem at the beginning. The main reason is that I am in the lower part of the middle line in the middle lane, as long as I go a little bit off. As soon as the dragon turns around, you take him down. That's it.

9 answers2024-03-14

c To convert lowercase letters to uppercase letters, ** is as follows: >>>More