How to write if condition

hai all i have assigned some value to the variable now i want to write if condition weather the value in the variable is in the format of P0123654 the starting P0 is fixed but the values after that will be varied but totally it would be of 8 digits how to write the if condition to check if the value in the variable is in the format of P0xxxxxx

it should check it should have 8 letters and starting should be P0

@bpt.teja1996 You could use a Regex and an IsMatch condition in the if.

2 Likes

Hi @bpt.teja1996

StringVariable.substring(0,2).Tostring.Equals(“P0”) And stringvariable.Length.Equals(8)

plz check with below screenshot

Thank you
Regards,
Gulshiyaa

3 Likes

Thank you somuch @gulshiyaa

If this’s your solution please mark as solution

Thank You,
Regards,
Gulshiyaa

@bpt.teja1996 - do the regex ismatch with expression … it improves your code quality…

^[p-pP-P][0]+[0-9]{6}$

2 Likes