[英]Regex for simple shuffle using String.replaceAll
What would be the regex for replaceAll()
that swaps adjacent chars? replaceAll()
相邻字符的replaceAll()
的正则表达式是什么?
For example, to turn this: 例如,将其转为:
abcdefg
into this: 到这个:
badcfeg
"abcdefg".replaceAll("(.)(.)", "$2$1")
这将返回badcfeg
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.