Write a Regex to extract number before '/'

前端 未结 5 548
情话喂你
情话喂你 2021-01-29 06:08

I don\'t want to use string split because I have numbers 1-99, and a column of string that contain \'#/#\' somewhere in the text.

How can I write a regex to extract the

5条回答
  •  一个人的身影
    2021-01-29 06:50

    Use a lookahead to match on the /, like this:

    \d+(?=/)
    

    You may need to escape the / if your implementation uses it as its delimiter.

    Live example: https://regex101.com/r/xdT4vq/1

提交回复
热议问题