The string search and lookup

The second group of functionalities is related to searching for the string. You can use methods such as startsWith(), endsWith(), and contains() to search for substrings in the beginning or end or in an arbitrary place in the string. The number of occurrences of a substring in the string can be retrieved using the count() method.

Be careful, there is also a count() method that doesn't take any parameters and returns the number of characters in the string.

If you need to know the exact position of the match, you can use indexOf() or lastIndexOf() to receive the position in the string where the match occurs. The first call works by searching forward, and the other one searches backwards. Each of these calls takes ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.