Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
String str = "abcde123_92qwq_1a_02x_1e";
我想用 0(零)替换前两个下划线( 92qwq )之间的第一个字符串部分。我怎样才能用正则表达式做到这一点?
例如: “abcde123_ 92qwq _1a_02x_1e”变为“abcde123_ 0 _1a_02x_1e” “abcde123_sdet4 _1a_02x_1e ”变为“abcde123_ 0 _1a_02x_1e”
我是正则表达式的新手,我尝试了一些。但我的情况有点紧急。
你可以使用类似的东西:
str = str.replaceFirst("_[^_]+_", "_o_");