|
SOLUTIONS
|
MATHEMATICA 内置符号
StringReplace
StringReplace["string", s->sp] 或 StringReplace["string", {s1->sp1, s2->sp2, ...}]
当
在
中出现时就用对应的
替换.
StringReplace["string", srules, n]
仅执行前 n 个替换.
StringReplace[{s1, s2, ...}, srules]
给出每个
的结果列表.
更多信息更多信息
- 字符串表达式
可以包含在 StringExpression 说明中指定的对象. - StringReplace 搜索一个字符串,并从字符串的第一个位置开始逐个检测子串. 对于每个子串,它按次序进行指定的变换规则. 如果某个规则被可用,就用子串替换,然后在从该子串后的字符开始新一轮测试.
- 如果
中的
不能计算为字符串,StringReplace 将产生一个 StringExpression 而不是一个普通字符串. - 在
形式的替换中,
直到每次使用时才进行计算. - 设置选项 IgnoreCase->True 使得 StringReplace 忽略大小写.
版本 2 的新功能 | 版本 5.1 修改功能
Mathematica 9 is now available!
New to Mathematica?
Find your learning path »
Have a question?
Ask support »
