---
title: "contains(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsstring/contains(_:)"
---

# contains(_:)

Returns a Boolean value indicating whether the string contains a given string by performing a case-sensitive, locale-unaware search.

## Declaration

```swift
func contains(_ str: String) -> Bool
```

## Parameters

- `str`: The string to search for. This value must not be nil.

## Return Value

Return Value true if the receiver contains str, otherwise false.

## Discussion

Discussion Calling this method is equivalent to calling range(of:options:) with no options. important: When working with text that’s presented to the user, use localizedStandardContains(_:) or localizedCaseInsensitiveContains(_:) instead.

## See Also

### Finding Characters and Substrings

- [localizedCaseInsensitiveContains(_:)](foundation/nsstring/localizedcaseinsensitivecontains(_:).md)
- [localizedStandardContains(_:)](foundation/nsstring/localizedstandardcontains(_:).md)
- [rangeOfCharacter(from:)](foundation/nsstring/rangeofcharacter(from:).md)
- [rangeOfCharacter(from:options:)](foundation/nsstring/rangeofcharacter(from:options:).md)
- [rangeOfCharacter(from:options:range:)](foundation/nsstring/rangeofcharacter(from:options:range:).md)
- [range(of:)](foundation/nsstring/range(of:).md)
- [range(of:options:)](foundation/nsstring/range(of:options:).md)
- [range(of:options:range:)](foundation/nsstring/range(of:options:range:).md)
- [range(of:options:range:locale:)](foundation/nsstring/range(of:options:range:locale:).md)
- [localizedStandardRange(of:)](foundation/nsstring/localizedstandardrange(of:).md)
- [enumerateLines(_:)](foundation/nsstring/enumeratelines(_:).md)
- [enumerateSubstrings(in:options:using:)](foundation/nsstring/enumeratesubstrings(in:options:using:).md)
