I've string data like this.
CFV - Certificat les Fondamentaux du Vin (en présentiel)(5)()
I want to retrieve the number from the second last bracket. This can be any number or numbers. I need help to get the right regex expression. The condition are followed:
- It can be any numbe
- r. No special character or string
- I only need the number. or an empty string.
CodePudding user response:
This regex gives you the number between the second last parentheses:
/(?<=\()\d (?=\)\(\)$)/
Explanation:
(?<=\()llok behind for a (
\d match one or more digits
(?=\)\(\)$) look ahead for )()
CodePudding user response:
Try
^(. \s )(............)(\d{0,5})
result in group 3. regex checks for 0 - 5 digits in the given ()
see Demo for more explanation
