How should I write regex to extract a substring from a string with the following conditions:
- Starting character should be
A - Last 2 characters should be
00. - Total length of string should be between 7 to 8
- Only numbers
Meaning A + 12345678 + 00
eg: Input: ABC12345678CRP1234567F2801209A1234567800<<<33
Output: 12345678
So far, I have tried below regex, but seems like I am missing something?
/(A(.*)00)/ (this fails because it doesnt match with the correct length
/(A(.*)00){7,8}/ (im not sure why this fails, but the idea was to keep the same as before and add the length restriction)
Any ideas?
A(\d+)00is enough.