<!--
{
  "availability" : [
    "iOS: 2.0.0 - 13.0.0",
    "iPadOS: 2.0.0 - 13.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.0.0 - 10.15.0",
    "tvOS: 9.0.0 - 13.0.0",
    "visionOS: 1.0.0 - 1.0.0",
    "watchOS: 2.0.0 - 6.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Scanner/scanCharacters(from:into:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSScanner(im)scanCharactersFromSet:intoString:"
  },
  "title" : "scanCharacters(from:into:)"
}
-->

# scanCharacters(from:into:)

Scans the string as long as characters from a given character set are encountered, accumulating characters into a string that’s returned by reference.

```
func scanCharacters(from set: CharacterSet, into result: AutoreleasingUnsafeMutablePointer<NSString?>?) -> Bool
```

## Parameters

`set`

The set of characters to scan.

`result`

Upon return, contains the characters scanned.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the receiver scanned any characters, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

Invoke this method with `NULL` as `stringValue` to simply scan past a given set of characters.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)