CHAPTER SIXTEEN283To test for a match you can use if and the =~ operat การแปล - CHAPTER SIXTEEN283To test for a match you can use if and the =~ operat ไทย วิธีการพูด

CHAPTER SIXTEEN283To test for a mat

CHAPTER SIXTEEN
283
To test for a match you can use if and the =~ operator: if_test.rb if /def/ =~ 'abcdef' The above expression evaluates to true if a match is made (and an integer is returned); it would evaluate to false if no match were made (and nil were re-turned): RegEx = /def/ Str1 = 'abcdef' Str2 = 'ghijkl' if RegEx =~ Str1 then puts( 'true' ) else puts( 'false' ) end #=> displays: true if RegEx =~ Str2 then puts( 'true' ) else puts( 'false' ) end #=> displays: false
Frequently, it is useful to attempt to match some expression from the very start of a string; the character ^ followed by a match term is used to specify this. It may also be useful to make a match from the end of the string; the character $ preceded by a match term is used to specify that. start_end1.rb puts( /^a/ =~ 'abc' ) #=> returns 0 puts( /^b/ =~ 'abc' ) #=> returns nil puts( /c$/ =~ 'abc' ) #=> returns 2 puts( /b$/ =~ 'abc' ) #=> returns nil
0/5000
จาก: -
เป็น: -
ผลลัพธ์ (ไทย) 1: [สำเนา]
คัดลอก!
บทที่หก283การทดสอบตรงกันคุณสามารถใช้และ = ~ ดำเนิน: if_test.rb ถ้า /def/ = ~ "abcdef" ข้างต้นนิพจน์เป็นจริงถ้าตรงกันจะทำได้ (และถูกส่งกลับเป็นเลขจำนวนเต็ม); มันจะประเมินเป็นเท็จถ้าจับคู่ไม่ได้ทำ (และ nil นั่นได้อีกเกลียด): RegEx /def/ Str1 = = 'abcdef' Str2 = 'ghijkl' ถ้า RegEx = ~ Str1 แล้วทำให้ทำให้อื่น ('จริง') ('เท็จ') จบ#= > แสดง: ถ้าจริง RegEx = ~ Str2 แล้วทำให้ทำให้อื่น ('จริง') ('เท็จ') จบ#= > แสดง: เท็จบ่อย ๆ เป็นประโยชน์พยายามให้ตรงกับนิพจน์บางพักสายอักขระ อักขระ ^ ตาม โดยตรง ใช้ระยะเพื่อระบุนี้ นอกจากนี้ยังอาจเป็นประโยชน์ทำให้การแข่งขันจากจุดสิ้นสุดของสตริ $ อักขระที่นำหน้า ด้วยคำที่ตรงกันระบุว่า ทำให้ start_end1.rb (/ ^ / = ~ 'abc') #= > กลับทำให้ 0 (/ ^ b / = ~ 'abc') #= > กลับทำให้ nil (/c$ / = ~ 'abc') #= > กลับทำให้ 2 (/b$ / = ~ 'abc') #= > กลับ nil
การแปล กรุณารอสักครู่..
ผลลัพธ์ (ไทย) 2:[สำเนา]
คัดลอก!
CHAPTER SIXTEEN
283
To test for a match you can use if and the =~ operator: if_test.rb if /def/ =~ 'abcdef' The above expression evaluates to true if a match is made (and an integer is returned); it would evaluate to false if no match were made (and nil were re-turned): RegEx = /def/ Str1 = 'abcdef' Str2 = 'ghijkl' if RegEx =~ Str1 then puts( 'true' ) else puts( 'false' ) end #=> displays: true if RegEx =~ Str2 then puts( 'true' ) else puts( 'false' ) end #=> displays: false
Frequently, it is useful to attempt to match some expression from the very start of a string; the character ^ followed by a match term is used to specify this. It may also be useful to make a match from the end of the string; the character $ preceded by a match term is used to specify that. start_end1.rb puts( /^a/ =~ 'abc' ) #=> returns 0 puts( /^b/ =~ 'abc' ) #=> returns nil puts( /c$/ =~ 'abc' ) #=> returns 2 puts( /b$/ =~ 'abc' ) #=> returns nil
การแปล กรุณารอสักครู่..
ผลลัพธ์ (ไทย) 3:[สำเนา]
คัดลอก!
บทที่ 16
0
ทดสอบสำหรับการแข่งขันที่คุณสามารถใช้ถ้าและ = ~ ) : if_test.rb ถ้า / def / = ~ ' ' abcdef ข้างต้นการแสดงออกประเมินจริงถ้าการแข่งขันถูกสร้าง ( และจำนวนเต็มกลับมา ) ; มันจะประเมินเท็จถ้าไม่ตรงกันได้ ( และนิลได้อีกครั้งเปิด ) : regex = / def / str1 = ' ' = ' ' abcdef str2 ghijkl ถ้า regex = ~ str1 แล้วใส่ ( จริง ) คนอื่นใส่ ( หลอกลวง ) # = > แสดง :ที่แท้จริงถ้า regex = ~ str2 แล้วใส่ ( จริง ) คนอื่นใส่ ( หลอกลวง ) # = > แสดง : เท็จ
บ่อย เป็นประโยชน์ในการพยายามที่จะตรงกับการแสดงออกบางอย่างตั้งแต่เริ่มต้นของสตริง ; ตัวละคร
ตามด้วยการแข่งขันในระยะใช้เพื่อระบุนี้ มันอาจจะมีประโยชน์เพื่อให้ตรงกับจากปลายสาย ; ตัวอักษร $ นำหน้าโดยตรงกับระยะที่ใช้ในการระบุว่า start_end1 .RB ใส่ ( /
/ = ~ ' ABC ' ) # = > จะได้ค่า 0 ให้ ( /
b / = ~ ' ABC ' ) # = > ผลตอบแทนนิลใส่ ( / / = c $ ~ ' ABC ' ) # = > ผลตอบแทน 2 ใส่ ( / / = b $ ~ ' ABC ' ) # = > ผลตอบแทนนิล
การแปล กรุณารอสักครู่..
 
ภาษาอื่น ๆ
การสนับสนุนเครื่องมือแปลภาษา: กรีก, กันนาดา, กาลิเชียน, คลิงออน, คอร์สิกา, คาซัค, คาตาลัน, คินยารวันดา, คีร์กิซ, คุชราต, จอร์เจีย, จีน, จีนดั้งเดิม, ชวา, ชิเชวา, ซามัว, ซีบัวโน, ซุนดา, ซูลู, ญี่ปุ่น, ดัตช์, ตรวจหาภาษา, ตุรกี, ทมิฬ, ทาจิก, ทาทาร์, นอร์เวย์, บอสเนีย, บัลแกเรีย, บาสก์, ปัญจาป, ฝรั่งเศส, พาชตู, ฟริเชียน, ฟินแลนด์, ฟิลิปปินส์, ภาษาอินโดนีเซี, มองโกเลีย, มัลทีส, มาซีโดเนีย, มาราฐี, มาลากาซี, มาลายาลัม, มาเลย์, ม้ง, ยิดดิช, ยูเครน, รัสเซีย, ละติน, ลักเซมเบิร์ก, ลัตเวีย, ลาว, ลิทัวเนีย, สวาฮิลี, สวีเดน, สิงหล, สินธี, สเปน, สโลวัก, สโลวีเนีย, อังกฤษ, อัมฮาริก, อาร์เซอร์ไบจัน, อาร์เมเนีย, อาหรับ, อิกโบ, อิตาลี, อุยกูร์, อุสเบกิสถาน, อูรดู, ฮังการี, ฮัวซา, ฮาวาย, ฮินดี, ฮีบรู, เกลิกสกอต, เกาหลี, เขมร, เคิร์ด, เช็ก, เซอร์เบียน, เซโซโท, เดนมาร์ก, เตลูกู, เติร์กเมน, เนปาล, เบงกอล, เบลารุส, เปอร์เซีย, เมารี, เมียนมา (พม่า), เยอรมัน, เวลส์, เวียดนาม, เอสเปอแรนโต, เอสโทเนีย, เฮติครีโอล, แอฟริกา, แอลเบเนีย, โคซา, โครเอเชีย, โชนา, โซมาลี, โปรตุเกส, โปแลนด์, โยรูบา, โรมาเนีย, โอเดีย (โอริยา), ไทย, ไอซ์แลนด์, ไอร์แลนด์, การแปลภาษา.

Copyright ©2025 I Love Translation. All reserved.

E-mail: