'How to extract number between [ ] by regex
I have a string as below:
53 12/Feb/2022 11:12:08 POST https 200 [1044ms]
I want to get the number in the text [xxxms] -> 1044
I use regex \d+ms, the result is 1044ms, but I want to get only the number.
Please help me with this issue.
Solution 1:[1]
Solution 2:[2]
You can get the value without lookarounds using a capture group:
\[(\d+)ms]
\[Match[(\d+)Capture 1+ digits in group 1ms]match literally
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tim Biegeleisen |
| Solution 2 | The fourth bird |
