开发者

Matching the first occurance of a number

开发者 https://www.devze.com 2023-03-12 02:08 出处:网络
In regex how would you match the number in the following string: first_occurrence_85 Would: ([0-9][0-9]) do?

In regex how would you match the number in the following string:

first_occurrence_85

Would: ([0-9][0-9]) do?

Edit: I meant to say any nu开发者_开发技巧mber of digits, so if its first_occurrence_8438, it should match 8438.


\d+ is enough.. \d matches with any digit..


How about this: ^.*[0-9]+.*$"
Will match any number of any character and after that atleast one numeric and then any number of any characters.

0

精彩评论

暂无评论...
验证码 换一张
取 消