dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Intermediate
May 8, 2020

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Determine if String str2 is a Rotation of String str1

Given two strings, str1 and str2, the code below shows a single line of code that returns whether or not str2 is a rotation of str1.

return (str1 + str1).matches("(?i).*" + Pattern.quote(str2) + ".*");
Octavia Anghel
 
Thanks for your registration, follow us on our social networks to keep up-to-date