Extract number from a string

Hi @Arnel
Just happened to see your post regarding the String operations in Katalon. Could you please assist me if the same syntax works in mobile as well.
I could find no inbuilt keyword ‘substring’, in the mobile Katalon .

My obtained string is App Login OTP : 570897.

I need to extract only the six digit number out of it. Could you please help?

Hi Janani,

Sorry for my late response…

Can you share your code here??

I think you can also do the same code in mobile, give it a try…

Thanks. . . .

String otp = Mobile.getAttribute(findTestObject(‘aa3/Mobile Number Verification - OTP/OTPReading/XCUIElementTypeCell - ABCDE verification code 703875 for mobile number xxxxxxxxxxxxx’), ‘name’, 0, FailureHandling.CONTINUE_ON_FAILURE)

otp1 = (otp.split('code ')[1]).substring(0, 6).trim()

println(otp1)

Get the attribute of your SMS ie name or label
assign to variable
trim the variable
use the variable

Thanks issue is been solved