gpt4 book ai didi

java - 从字符串中提取字符和整数

转载 作者:行者123 更新时间:2023-12-01 15:44:47 27 4
gpt4 key购买 nike

我有这个字符串 p="V755D888B154",我想将其拆分为这种形式

  • V
  • 755
  • D
  • 888
  • B
  • 154

我该怎么做?提前致谢

最佳答案

您可以使用String.split 。示例:

String[] numbers = p.split("[a-zA-Z]+");
String[] letters = p.split("[0-9]+");

数字字母可以有空字符串,但您可以手动检查。

关于java - 从字符串中提取字符和整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7277056/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com