标签云

微信群

扫码加入我们

WeChat QR Code

Usually I would expect a String.contains() method, but there doesn't seem to be one. What is a reasonable way to check for this?


dimpiax, you've restored the example using match that Ry- deliberately chose to remove. Why? It's not necessarily wrong to have it here, but what advantage does it have over indexOf? What's the motivation for ever using it over one of the other two options? If there's no justification, then it probably isn't useful to include the option at all. If there is a justification, then it'd be helpful to include it in the answer. (Also, I don't like the example you've added, since it doesn't make clear that the argument to .match() is a regex; as written this laysa trap for the reader.)

2019年04月22日05分21秒