Swift Basics-String

Source: Internet
Author: User

(1) Traverse

(2) Length

(3) Splicing

(4) interpolation

(5) Case

(6) Trim

(7) Split

...... Wait a minute

  1. var a = "Hello"
  2. var B = String ()
  3. A. IsEmpty
  4. b = "xxxxxyyyyy"
  5. b. IsEmpty
  6. Traverse
  7. For C in B {
  8. println (c)
  9. }
  10. Calculate length
  11. Countelements (b)
  12. Stitching
  13. A + = b
  14. Interpolated values
  15. var Strss = "A: \ (a), B: \ (b)"
  16. Comparison
  17. Let str_a = "abc"
  18. Let Str_b = "abc"
  19. Str_a = = Str_b
  20. Dictionary order Comparison
  21. Let Str_c = "Abd"
  22. Str_b < Str_c
  23. Front and rear prefix
  24. Str_b. Hasprefix ("a")
  25. Str_b. Hassuffix ("C")
  26. Uppercase and lowercase conversions
  27. Str_b. uppercasestring
  28. Str_b. lowercasestring
  29. Capitalize the first letter of each word
  30. Let str_d = ' I am a good person '
  31. Str_d. capitalizedstring
  32. Trim operation
  33. var s1 = "xx xx"
  34. S1. Stringbytrimmingcharactersinset (Nscharacterset. Whitespacecharacterset ())
  35. S1. Stringbytrimmingcharactersinset (Nscharacterset (charactersinstring:""))
  36. Split operation
  37. var s2 = "I am a good boy"
  38. S2. componentsseparatedbystring ("")
  39. S2. Componentsseparatedbycharactersinset (Nscharacterset (charactersinstring: "a"))

Swift Basics-String

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.