TAILIEUCHUNG - Manipulating Strings

Thao tác Strings Cho đến nay, chúng tôi đã xử lý chủ yếu là với các con số. Bây giờ là lúc để tìm hiểu về những phương pháp mạnh mẽ của lớp String, mà bạn đã được giới thiệu trong Bài 4, "Sử dụng lớp Object." Sử dụng phương pháp lớp String, bạn có thể tìm thấy các nhân vật cụ thể trong một chuỗi, thay đổi trường hợp của chuỗi, đảo ngược các ký tự trong chuỗi, và nhiều hơn nữa | Manipulating Strings So far we ve dealt mostly with numbers. Now it s time to learn about the powerful methods of the String class to which you were introduced in Lesson 4 Using Object Classes. Using String class methods you can find specific characters in a string change the case of the string reverse the characters in the string and more. Here are some of the most commonly used String class methods length This String class property returns the number of characters in a string. For example var numCharacters Number Here the value of numCharacters is based on the number of characters in the userName variable. If userName is Jobe the result is 4. substr start length The substring method which returns part of a string accepts two parameters starting index and the length or number of characters to count including starting character . If the length parameter is omitted this method will by default count until the end of the string. For example 1 2 If the value of name is Kelly the result would be el . The letter e has an index of 1 and the number 2 tells the substring to include two letters. toLowerCase This method forces all of the letters in a string to be lowercase. For example If the value of message is Hello the result is hello . toUpperCase This method forces all of the letters in a string to be uppercase. For example If the value of message is Hello the result is HELLO . NOTE As explained in Lesson 4 Using Object Classes the text property of a text field instance can also be considered an instance of the String class and can be manipulated as such. For example causes all the text in the myTextField_txt text field to appear in uppercase letters. In this exercise you create a simple silly word-game application. You enter words in a basic form and a paragraph will be generated. 1. Open in the Lesson06 Assets folder. This file includes three layers .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.