假设我有一个字符串val s = "_1.2V_ADC"
该句点对我的用例无效,因此我需要将其替换为另一个字符,例如p最终字符串应该是"_1p2V_ADC"
在 Stanza 中是否有任何简单的方法可以做到这一点?
假设我有一个字符串val s = "_1.2V_ADC"
该句点对我的用例无效,因此我需要将其替换为另一个字符,例如p最终字符串应该是"_1p2V_ADC"
在 Stanza 中是否有任何简单的方法可以做到这一点?
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".
您需要包中的此功能core:
public defn replace (str:String, s1:String, s2:String) -> String
你的例子变成replace("_1.2V_ADC", ".", "p")
了_1p2V_ADC