If I use string.contains() on a string that may have regular expressions

If I use string.contains() on a string that may have regular expressions, will the regular expressions trigger? For example string.contains("alpha\wbet").

Am I right in thinking that contains will be fine but matches will not? Thank you


String.contains() accepts CharSequence as argument and doesn't "trigger" regexes that it or processing string may contain.

Returns true if and only if this string contains the specified sequence of char values.

From here.

Contains take a string as parameter and looks for that string. It doesn't work as regexp. If you want to search for regular experssion use string.matches

It accepts char sequence as a paramater. If you give regex contains method consider that as char sequence. Below provide sample program depict the behavior.

 String inp="12345";
 Matcher m=Pattern.compile("\\d+").matcher(inp);



The output of the testcase shows how it contains method works for regex.

Need Your Help

Convert CATransform3D into CIVector's for CIPerspectiveTransform, replace UIGetScreenImage

ios objective-c core-image gpuimage catransform3d

Is it possible to convert a CATransform3D into a set of CIVectors in order to transform a UIImage with a CATransform3D?

C#/XNA/HLSL - How to create depth of field?

c# xna hlsl

I'm trying to create a depth of field post process, but have no idea where to start (except render depth map, which I'm currently at). All the tutorials for it are either for XNA3.1, don't actually...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.