I have a broadcast receiver which listens for sms. When Sms arrives I have the whole text but am concerned with only the OTP.

My challenge is how to extract the 6 digit otp. I can't use regex because sms format might change.

example " Thanks for registering your otp is 123456"

I want 123456. sms structure can change but otp will always be a 6 digit figure