1. replace_string(3) LP MudOSv21c7 (7 Jul 1996)
    2. 函数名称:
    3. replace_string() - 替换一个字串中符合条件的字.
    4. 函数语法:
    5. string replace_string( str, pattern, replace );
    6. string replace_string( str, pattern, replace, max );
    7. string replace_string( str, pattern, replace, first, last );
    8. string str, pattern replace;
    9. int max, first, last;
    10. 字串 replace_string( str, pattern, replace );
    11. 字串 replace_string( str, pattern, replace, max );
    12. 字串 replace_string( str, pattern, replace, first, last );
    13. 字串 str, pattern replace;
    14. 整数 max, first, last;
    15. 函数用法:
    16. replace_string() str 中所有符合条件的字 pattern 替换成
    17. 指定的字 replace. 如果 pattern 没有内容 (为零) , 就传回原
    18. 来的 str . 如果传回的字串超过定义的最大字串长度, 则传回一
    19. undefindp() 传回 1, stringp() 传回 0 的值.
    20. replace_string() 可以指定 replace 为空的字串, 以用来除去
    21. 字串中特定的字. 举例来说: replace_string(" 1 2 3 ", " ", "")
    22. 会传回 "123". replace_string() 执行的速度比用 explode()
    23. implode() 快.
    24. 第四和第五个参数可有可无 (这是为了相容於以前的版本). 这两个
    25. 附加的参数有以下的功用:
    26. 第四个参数 first:
    27. 指定同一个字串最多替换几次 (从 1 开始算). 如果这里指定为 0,
    28. 就当作是全部都换. 所以 replace_string("xyxx", "x", "z", 2)
    29. 会传回 "zyzx".
    30. 第五个参数 last:
    31. 第五个参数限制符合条件的□围:
    32. first < 1: 从头开始全部替换.
    33. last == 0 last > 最高符合数(max_matches): 全部替换到最後.
    34. first > last: 完全不改变.
    35. 举例: replace_string("xyxxy", "x", "z", 2, 3) 传回 "xyzzy".
    36. 参考函数:
    37. sscanf(3), explode(3), strsrch(3)
    38. 作者:
    39. Zak@TMI-2 撰写限制条件的部份.
    40. 手册翻译:
    41. Phoebus@ZH 97.Jun.2. (Writen 5/23/97)