gpt4 book ai didi

java - 什么等同于 Java 中的 rfind(来自 python)?

转载 作者:行者123 更新时间:2023-11-30 08:54:33 25 4
gpt4 key购买 nike

我需要一个函数来搜索右侧的输入。我想从右边(而不是像使用 .find 那样从左边)找到第一个“)”。

.rfind 来自 python,所以我需要它在 Java 中的等效项。

有什么想法吗?谢谢!!

最佳答案

假设您正在使用字符串,方法 lastIndexOf()似乎符合您的需求。

Java文档:

Returns the index within this string of the last occurrence of the specified character.

The String is searched backwards starting at the last character.

关于java - 什么等同于 Java 中的 rfind(来自 python)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29359539/

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