Regular expression to get number before and after a string


I need a regular expression to get numbers before and after a string.
For example the string is as follows.
ex- RECORDS 1 TO 21 OF 38 10/30/18 06:26:53 1 M3LL

I want the numbers before and after the string “OF” I .e 21 and 38(that regular expression should support if number is more than 2(21 or 38) digits like for (102 of 986)). I tried with normal expression but not succeed.

Can anyone help me in getting the regular expression for getting numbers before and after regular expressions.

Thanks and Regards,


Can you try this regex
Integer before “OF” (\d+)(?=\s*OF)

Integer after “OF” (?<=OF\s*)(\d+)


([\d]{1,}?)(?=OF)(.+?)([\d]{1,}) (?=[\d]{2}[/][\d]{2}[/][\d]{2})?