0

假设我有一个字符串val s = "_1.2V_ADC"

该句点对我的用例无效,因此我需要将其替换为另一个字符,例如p最终字符串应该是"_1p2V_ADC"

在 Stanza 中是否有任何简单的方法可以做到这一点?

4

2 回答 2

1

You can use the replace function for this:

val s = replace("_1.2V_ADC", ".", "p")

It will replace all matches of the string "." with the string "p".

于 2021-07-27T21:08:35.187 回答
0

您需要包中的此功能core

public defn replace (str:String, s1:String, s2:String) -> String

你的例子变成replace("_1.2V_ADC", ".", "p")_1p2V_ADC

于 2021-07-27T21:11:21.247 回答