Delphi Programming Replace the character in the nth position, how does it work?

Updated on technology 2024-04-08
12 answers
  1. Anonymous users2024-02-07

    Send you a function:

    def replacestring(string, num, replace):

    string2 = ''

    for i in range(len(string)):

    if i == num:

    string2 += replace

    else:string2 += string[i]

    return string2

    Example: >>replacestring('abc', 1, 'a')

    aac'

  2. Anonymous users2024-02-06

    1. First enter **:

    #include

    #include

    Parameters: originalstring: original string * key: string to be replaced.

    swap: New string.

    void replace(char originalstring, char key, char swap);

    char key = ;

    char swap = ;

    replace(originalstring, key, swap);

    printf("%s", originalstring);

    return 0;

    5. That's it.

  3. Anonymous users2024-02-05

    #include

    #include

    #include

    Replace t in strres with s, and return 1 if the replacement is successful, otherwise 0 is returned.

    int strreplace(char strres,char from, char to) }

    return flag;

    int main()

  4. Anonymous users2024-02-04

    The principle is the same. Find the keyword terms. You can use the strstr() library function.

    Use strcpy to replace the function. But consider the length of the word to be replaced and the length of the word to be replaced. Do a good job of shifting other strings and allocating space for string length changes.

  5. Anonymous users2024-02-03

    Upstairs explained the basics.

  6. Anonymous users2024-02-02

    showmessage(stringreplace (astr, 'a', 'two', )//this is two book, not a pen!Only the first word that meets the requirements of the pass has been replaced.

    showmessage(stringreplace (astr, 'a', 'two', [rfreplaceall]))//this is two book, not two pen!The compilation has been indicated, and I am d7 and tested it myself.

  7. Anonymous users2024-02-01

    Delphi's stringreplace string substitution function.

    function stringreplace (const s, oldpattern, newpattern: string; flags: treplaceflags):

    string;

    rfreplaceall: replaces all.

    rfignorecase: Ignores case.

    for example:

    varastr: string;

    beginastr := 'this is a book, not a pen!';

    showmessage(stringreplace (astr, 'a', 'two', )//this is two book, not a pen!Only the first word that matches has been replaced.

    showmessage(stringreplace (astr, 'a', 'two', [rfreplaceall]))//this is two book, not two pen!Replaced all words that matched.

    astr := 'this is a book, not a pen!';

    showmessage(stringreplace (astr, 'a', 'two', [rfreplaceall]))//this is two book, not a pen!Only the words that match (lowercase a) have been replaced

    showmessage(stringreplace (astr, 'a', 'two', [rfreplaceall, rfignorecase]))//this is two book, not two pen!Regardless of case, all matching words are replaced.

    end;

  8. Anonymous users2024-01-31

    It is known that a library book is sorted alphabetically by the title of the book, forming n strings, and the idea of half-fold search is used to program to find the location of the specified string in n strings.

    This is what I made, but the program always runs wrong. Pray for the great gods.

  9. Anonymous users2024-01-30

    It is sent on the Kung Fu Embassy.

  10. Anonymous users2024-01-29

    The materials that need to be prepared are: computer and C language compiler.

    1. First of all, open the C language compiler and create a new initial. CPP file, for example:

    2. In the file, enter C language**:

    char a = "hello world!", b[20];

    strrpl(a, b, sizeof(b), "world", "c");

    puts(a);

    3. The compiler runs the file, and at this time it will be successful"world"Replace with"c"The output was made.

  11. Anonymous users2024-01-28

    It doesn't seem like there is, you can write one yourself.

    #include

    #include

    main()

  12. Anonymous users2024-01-27

    copy(‘2013314’,1,4)+'0'+copy(‘2013314’,5,3)

    If you just choose a string in time format, you can do it another way:

    formatdatetime('yyyymmdd',now);now is the current time. Replace with the time you want to display.

Related questions
7 answers2024-04-08

When we want to replace a file that is running on the system, it is very troublesome, and sometimes we have to go into safe mode. It is useful to find a DOS command that can replace a running file under the XP system. >>>More

12 answers2024-04-08

Executed in one data control.

alter table name alter column id counter (1, 1). >>>More

8 answers2024-04-08

To provide a little bit of my learning experience is as follows: >>>More

11 answers2024-04-08

I don't know what event you put it in, mine is in the paste click of the floating menu.

12 answers2024-04-08

1. Press and hold "Ctrl+H" to bring up the "Find and Replace" dialog box, and fill in the "Find content" field. >>>More