16
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Swift]文字列検索で範囲と位置の取得

16
Last updated at Posted at 2014-07-28

指定した文字列の検索は以下の通りです。

コード

//文字列の範囲を取得
var str: NSString = "abcdefghi"
var range: NSRange = str.rangeOfString("cde")
println(range)

//文字列の位置を取得
var loc = str.rangeOfString("cde").location
println(loc)

出力結果

(2,3)
2

16
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?