Mathematica怎么进行字符串匹配

2024-10-13 10:03:35

1、Mathematica用StringCases进行字符串的匹配:StringCases["Mathematica用 StringCases进行字符串的匹配:", "用" ~~ __ ~~ ":"]这个代码的作用,就是把前面字符串里面,"用"和":"之间的字符串匹配出来。

Mathematica怎么进行字符串匹配

3、IgnoreCase指定,是否忽略字母的大小写:StringCases["IgnoreCase specifies Whet茑霁酌绡her to ignore the Letter \size:", "i" ~~ __ ~~ "o", IgnoreCase -> True]可以看到,有或没有IgnoreCase -> True,返回的结果还是有区别的。

Mathematica怎么进行字符串匹配

5、这里有两个电话号码:(0531)19999999,(010)89590727,怎么把号码匹配出来?StringCases["这里有两个电话号码:(0531)19999999,(010)89590727,怎么把号码匹配出来?","(" ~~ DigitCharacter .. ~~ ")" ~~ DigitCharacter ..]

Mathematica怎么进行字符串匹配
猜你喜欢