我有这个URL:
http://localhost:8888/alain-pers/fr/oeuvres/architecture/
我想要将倒数第二个
/
替换为#
(我需要最后一个/
),并获得以下输出结果:http://localhost:8888/alain-pers/fr/oeuvres#architecture/
我已经尝试了很多使用
indexOf()
,lastIndexOf()
和 substr()
的方法,但我没能得到想要的结果。任何正则表达式的解决方案都不能正常工作。请注意有时链接也会像这样带有一个
-
:http://localhost:8888/alain-pers/fr/oeuvres/art-contemporain/