[swift-users] What are these types with regular expressions?

Saagar Jha saagar at saagarjha.com
Sat Aug 6 13:09:29 CDT 2016


Swift String indexing and sub scripting is different than other languages.
Instead of using Ints, Strings use their own Indexes (a String.Index). To
get an index, you can use the String's startIndex property and then use
advancedBy on it. The Swift Programming Language has more details:
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/StringsAndCharacters.html#//apple_ref/doc/uid/TP40014097-CH7-ID285

On Sat, Aug 6, 2016 at 04:26 晓敏 褚 <swift-users at swift.org> wrote:

> I’m writing a program with regular expressions, and I’m finding it
> extremely hard to code with these in swift. I got a [TextCheckingResult]
> from the matching function, and there is no document on what
> TextCheckingResult is and how could I work with it. And when I try to use
> range to get a substring, I got a Range<Int>, but the substring:with:
> method requies a Range<Index>. But there is no way I could find any
> information about the type(or protocol?) Index, and passing a Int fails.
> What are they, and how can I work with them?
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160806/ad33f586/attachment.html>


More information about the swift-users mailing list