gpt4 book ai didi

java - 使用正则表达式在android中将字符串拆分为多个字符串

转载 作者:行者123 更新时间:2023-11-29 05:08:21 24 4
gpt4 key购买 nike

我正在做一个 android 项目,做与解析相关的事情。假设我想将字符串拆分为自定义格式

我的字符串

Power supply will be suspended in the following areas on 13-04-15 between 9.00 A.M. to 2.00 P.M. for maintenance work. NUNGAMBAKKAM AREA : Nungambakkam High road(Door no. 33 to 66), Ponnankipuram, Avenue road, New street. TI CYCLE AREA : Cholapuram Main road, Complete Thiruvenkata nagar, Stedford Hospital, Lenin nagar, Teachers colony, Sivananda nagar, Municipal Court and CTH road, Post office, Railway station road, School area, Ramapuram, South park st, Ambattur market, Thasildhar office

所以我想把字符串拆分成这样

Power supply will be suspended in the following areas on 13-04-15 between 9.00 A.M. to 2.00 P.M. for maintenance work
NUNGAMBAKKAM AREA
Nungambakkam High road(Door no. 33 to 66)
Ponnankipuram
Avenue road
...........
Thasildhar office

那么我怎样才能让这个android.help我得到值

最佳答案

(?<=[a-z])\.(?=\s*[A-Z])|[,:]

你可以试试这个。看演示。

https://regex101.com/r/sJ9gM7/88

对于java来说就是

(?<=[a-z])\\.(?=\\s*[A-Z])|[,:]

关于java - 使用正则表达式在android中将字符串拆分为多个字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29619483/

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