简体   繁体   中英

Remove part from string in java

Guys i have that string page-116.jpg and i want it to be page.jpg my trail is

text.replaceAll("^[\\-|\\d]+", "")

but it doesn't give me the desired output ... any help ??

您可以使用-\\\\d+将匹配-numbers

text = text.replaceAll("-\\d+", "");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM