Regex to find text between second and third slashes

后端 未结 6 1966
夕颜
夕颜 2020-11-29 07:48

I would like to capture the text that occurs after the second slash and before the third slash in a string. Example:

/ipaddress/databasename/

I need to capt

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 08:13

    /.*?/(.*?)/
    

    In the event that your lines always have / at the end of the line:

    ([^/]*)/$
    

    Alternate split method:

    split("/")[2]
    

提交回复
热议问题