Find the first occurrence with Regex and Java

前端 未结 3 885
不知归路
不知归路 2020-12-03 22:42

I would like to be able to find the first occurrence of m² and then numbers in front of it, could be integers or decimal numbers. E.g.

"som

3条回答
  •  伪装坚强ぢ
    2020-12-03 23:09

    One simple way of doing it!

    description.replaceFirst(@NotNull String regex,
                               @NotNull String replacement)
    

    JAVADoc: Replaces the first substring of this string that matches the given regular expression with the given replacement.

提交回复
热议问题