+ 3

What is the output of the following code?

Sop("Hi, ABC, good".matches("ABC ")+" "); Sop("Hi, ABC, good".matches(".*ABC.*")); Output: false true How this code works? Please help!

6th Dec 2020, 6:07 AM
SHREYA UPADHYAY
SHREYA UPADHYAY - avatar
4 Respuestas
+ 2
SHREYA UPADHYAY. In the first code, in String there is no space after ABC but in the matches method there is space after ABC. So it return false. In the second code there is no space in String but there is .* before and after the ABC in matches method. Here .* ignore everything and returns true.
6th Dec 2020, 7:25 AM
A͢J
A͢J - avatar
+ 1
AJ #Learn With Me 👨‍💻 thank you very much 😊
6th Dec 2020, 8:46 AM
SHREYA UPADHYAY
SHREYA UPADHYAY - avatar
+ 1
Coder Kitten thank you very much 😊
6th Dec 2020, 8:46 AM
SHREYA UPADHYAY
SHREYA UPADHYAY - avatar