Why do regular expressions in Java and Perl act differently?

前端 未结 2 378
我寻月下人不归
我寻月下人不归 2020-12-10 03:52

My understanding is that Java\'s implementation of regular expressions is based on Perl\'s. However, in the following example, if I execute the same regex with the same str

2条回答
  •  失恋的感觉
    2020-12-10 04:03

    The Java matches method is testing whether the regex matches the entire String. To test whether a regex can be found anywhere in a string, create a Matcher and use its find method.

提交回复
热议问题