<!--
{
  "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/scanUpTo(_:into:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSScanner(im)scanUpToString:intoString:"
  },
  "title" : "scanUpTo(_:into:)"
}
-->

# scanUpTo(_:into:)

Scans the string until a given string is encountered, accumulating characters into a string that’s returned by reference.

```
func scanUpTo(_ string: String, into result: AutoreleasingUnsafeMutablePointer<NSString?>?) -> Bool
```

## Parameters

`string`

The string to scan up to.

`result`

Upon return, contains any characters that were scanned.

## Return Value

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

  If the only scanned characters are in the [`charactersToBeSkipped`](/documentation/Foundation/Scanner/charactersToBeSkipped)   character set (which by default is the whitespace and newline character set), then this method returns   <doc://com.apple.documentation/documentation/Swift/false>  .

## Discussion

If `stopString` is present in the receiver, then on return the scan location is set to the beginning of that string.

If `stopString` is the first string in the receiver, then the method returns <doc://com.apple.documentation/documentation/Swift/false> and `stringValue` is not changed.

If the search string (`stopString`) isn’t present in the scanner’s source string, the remainder of the source string is put into `stringValue`, the receiver’s `scanLocation` is advanced to the end of the source string, and the method returns <doc://com.apple.documentation/documentation/Swift/true>.

Invoke this method with `NULL` as `stringValue` to simply scan up to a given string.

---

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)