Tagged: replace()

Android : How to remove or replace alphabets in String

การลบคำหรือแทนที่คำในข้อความของตัวแปรแบบ String บน Android เราใช้ฟังก์ชัน .replace(), .replaceAll() ได้ครับ โดยมีรูปแบบการเรียกใช้ดังนี้ <String>.replace(“alphabet to remove”, “alphabet to replace”); <String>.replaceAll(“alphabet to remove”, “alphabet to replace”); ตัวอย่าง1 สมมติว่ามีตัวแปร String A = “12-04-2018” ต้องการเอาเครื่องหมาย “-” ออก เราสามารถใช้ฟังกชัน .replace() ดังนี้ String...