wind_gan
wind_gan

Reputation: 132

How to check if one pattern is included into another

For example, I have the following regular expression:

/lol.*

All strings that matches this expression also matches another expression:

/l.*

How to check that first regex is included into the second one (using JAVA libraries)?

Upvotes: 0

Views: 45

Answers (1)

Avinash Raj
Avinash Raj

Reputation: 174776

You need to use a lookahead in the second regex inorder to check if the first regex is present in the second or not.

\/l(?=ol).*

In java you don't need to escape forward slash. So the below regex would be enough.

l(?=ol).*

DEMO

Upvotes: 1

Related Questions