What is the use of Pattern.quote method?

后端 未结 6 1937
春和景丽
春和景丽 2020-11-27 02:59

I\'m trying to understand Pattern.quote using the following code:

String pattern = Pattern.quote("1252343% 8 567 hdfg gf^$545");
System         


        
6条回答
  •  臣服心动
    2020-11-27 03:31

    Regex collides frequently with normal strings. Say I want a regex to search for a certain string that is only known at runtime. How can we be sure that the string doesn't have regex meaning eg(".*.*.*")? We quote it.

提交回复
热议问题