After the call, the match_results object m has a state, which is visible in Figure 14.1 and provides the following interface:
• In general, the match_results object contains:
– A sub_match object m[0] for all the matched characters
– A prefix(), a sub_match object that represents all characters before the first matched character
– A suffix(), a sub_match object that represents all characters after the last matched character
• In addition, for any capture group, you have access to a corresponding sub_match object m[n].
Because the regex specified here defines three capture groups, one for the introducing tag, one
for the value, and one for the ending tag, these are available in m[1], m[2], and m[3].
• size() yields the number of sub_match objects (including m[0]).
• All sub_match objects are derived from pair and have the position of the first character as
member first and the position after the last character as member second. In addition, str()
yields the characters as a string, length() yields the number of characters, operator
หลังจากโทร , match_results วัตถุ M มีสถานะ ซึ่งจะปรากฏในรูปที่ 14.1 และมีอินเตอร์เฟซดังต่อไปนี้ :
- ทั่วไป match_results วัตถุประกอบด้วย :
( [ m วัตถุ sub_match 0 ] สำหรับทุกอักขระที่ตรงกับ
3 prefix() , sub_match วัตถุที่แสดงถึงตัวละครทุกตัวก่อนจึงตัดสินใจเดินทางจับคู่ตัวอักษรและ suffix()
,เป็น sub_match วัตถุที่แสดงถึงตัวละครทุกตัว หลังจากล่าสุดจับคู่ตัวละคร
- นอกจากนี้ใด ๆจับ กลุ่ม คุณมีการเข้าถึงที่ sub_match วัตถุ M [ N ] .
เพราะ regex speci จึงเอ็ด เดอ จึงไม่จับสามกลุ่มหนึ่งเพื่อแนะนำแท็กหนึ่ง
ค่าหนึ่ง สำหรับตอนจบของแท็กเหล่านี้มีอยู่ใน M [ 1 ] , M [ 2 ] และ m
[ 3 ]บริการ size() ผลผลิตจำนวน sub_match วัตถุ ( รวมทั้ง m [ 0 ] )
- sub_match วัตถุทั้งหมดจะมาจากคู่ < และมีตำแหน่งของจึงตัดสินใจเดินทางไป ตัวละครที่
สมาชิกครั้งแรกและตำแหน่งหลังตัวสุดท้ายที่สมาชิก 2 นอกจากนี้ str()
เพิ่มตัวละครเป็นสตริง , length() ผลผลิตจำนวนตัวอักษร ( < < เขียนตัวอักษรไปยังลำธารและแยกประเภทการแปลงสตริงเป็น de จึงเน็ด .
บริการนอกจากนี้ วัตถุ match_results ทั้งมีฟังก์ชัน :
( สมาชิก str() ให้ผลตรงกับสตริงโดยรวม ( เรียก str() หรือ STR ( 0 )
หรือแลกจับคู่ข้อความ STR ( N ) ( โทร ) ซึ่งว่างเปล่าถ้าไม่ตรงกับข้อความที่มีอยู่
( ดังนั้น ผู้ผ่าน N มากกว่า size() ใช้ได้ )
- ฟังก์ชันสมาชิก length() ให้ผลตรงกับความยาวของสตริงโดยรวม ( เรียก length() หรือความยาว ( 0 ) หรือแลกกับความยาวของข้อความ ( เรียกความยาว ( n ) ซึ่งเป็น 0 ถ้าไม่ตรงกับข้อความที่มีอยู่ ( ซึ่งผ่านการ n มากกว่า size() ใช้ได้ )
- ฟังก์ชันสมาชิก position() ผลผลิตตำแหน่งของการจับคู่สตริงโดยรวม ( โทร - ing position() หรือตำแหน่ง ( 0 ) หรือแลกกับตำแหน่งของข้อความ ( เรียกความยาว ( n )
( ฟังก์ชันสมาชิก begin() cbegin() end() cend() , , , และองค์ประกอบทาง sub_match
วัตถุ m [ 0 ] M [ N ]
สำหรับเหตุผลนี้ โปรแกรมมีการแสดงผลดังต่อไปนี้ :
การแปล กรุณารอสักครู่..
![](//thimg.ilovetranslation.com/pic/loading_3.gif?v=b9814dd30c1d7c59_8619)