A PHP Error was encountered
Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Category_model_SelectMainMenu.cache): No such file or directory
Filename: drivers/Cache_file.php
Line Number: 279
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Category_model.php
Line: 53
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 106
Function: SelectMainMenu
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: file_get_contents(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeyaddress.cache): failed to open stream: No such file or directory
Filename: drivers/Cache_file.php
Line Number: 275
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 122
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Notice
Message: Trying to access array offset on value of type bool
Filename: drivers/Cache_file.php
Line Number: 277
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 122
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeyfacebook.cache): No such file or directory
Filename: drivers/Cache_file.php
Line Number: 279
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 126
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: file_get_contents(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeyqr_zalo_group.cache): failed to open stream: No such file or directory
Filename: drivers/Cache_file.php
Line Number: 275
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 129
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Notice
Message: Trying to access array offset on value of type bool
Filename: drivers/Cache_file.php
Line Number: 277
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 129
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeyfanpage_facebook.cache): No such file or directory
Filename: drivers/Cache_file.php
Line Number: 279
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 131
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeyapp_id.cache): No such file or directory
Filename: drivers/Cache_file.php
Line Number: 279
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 133
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeybanner_home.cache): No such file or directory
Filename: drivers/Cache_file.php
Line Number: 279
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 136
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
[Performance JMeter] Bài 7 - Post Processors Regular Expression Extractor | Anh Tester
NỘI
DUNG BÀI HỌC
✅ Giới thiệu
✅ Cấu trúc cơ bản của Regex
✅ Regular Expression Extractor
✅ Ví dụ minh họa
1. Regex là gì?
Regex (Regular Expression) : Cú pháp đặc biệt dùng để tìm kiếm, so khớp và xử lý chuỗi văn bản.
Ứng dụng:
2. Cấu trúc cơ bản của Regex
🔹 Ký tự thường
Khớp chính xác ký tự. Ví dụ: abc khớp với "abc".
🔹 Metacharacters (ký tự đặc biệt)
Ký hiệu
Ý nghĩa
Ví dụ
.
Bất kỳ ký tự nào
a.c khớp "abc", "a1c"
^
Bắt đầu chuỗi
^Hello khớp "Hello world"
$
Kết thúc chuỗi
world$ khớp "Hello world"
*
Lặp lại 0 hoặc nhiều lần
ab* khớp "a", "abbb"
+
Lặp lại 1 hoặc nhiều lần
ab+ khớp "ab", "abbb"
?
0 hoặc 1 lần
colou?r khớp "color", "colour"
{n}
Lặp đúng n lần
\d{3} khớp "123"
{n,m}
Lặp từ n đến m lần
a{2,4} khớp "aa", "aaa", "aaaa"
[]
Một ký tự trong tập
[abc] khớp "a", "b", "c"
()
Nhóm
(abc)+ khớp "abcabc"
|
OR (hoặc)
cat|dog khớp "cat" hoặc "dog"
🔹 Nhóm ký tự viết tắt
Ký hiệu
Ý nghĩa
Ví dụ
\d
Chữ số (0-9)
\d\d → "12"
\w
Ký tự chữ/số/_
\w+ → "abc123"
\s
Khoảng trắng
\s → " " hoặc \t
\D
Không phải số
\D → "a"
\W
Không phải ký tự chữ/số
\W → "!"
\S
Không phải khoảng trắng
\S → "a"
3. Regular Expression Extractor
a. Khái niệm
Regular Expression Extractor là một Post-Processor trong JMeter .
Chức năng: trích xuất dữ liệu từ response (HTML, JSON, XML, text…) dựa vào biểu thức Regex.
Dữ liệu trích xuất sẽ được lưu vào biến để dùng cho các request tiếp theo.
👉 Thêm bằng cách:Right click → Add → Post Processors → Regular Expression Extractor.
b. Các trường cấu hình chính
Trường
Ý nghĩa
Name
Tên của Extractor (tùy chọn).
Apply to
Áp dụng cho: Main sample, Sub-samples, Both…
Field to check
Chọn nội dung cần so khớp: Response Body, Headers, URL, Response Code, Response Message.
Reference Name
Tên biến lưu giá trị trích xuất (ví dụ: sessionId).
Regular Expression
Biểu thức Regex để trích xuất.
Template
Chỉ định group nào trong regex được lưu, thường là $1$.
Match No.
Chọn kết quả: 1 = kết quả đầu tiên, -1 = tất cả.
Default Value
Giá trị mặc định nếu không tìm thấy kết quả.
4. Ví dụ
Câu 1 – JSON Response
Response:
Cần trích xuất: token
Regex nào đúng?
A. "token": "(.*?)"
B. "username": "(.*?)"
C. "token":\s*"(.*?)" ✅
D. "id": (\d+)
👉 Đáp án: C (vì xử lý được khoảng trắng).
Câu 2 – HTML Response
Response:
Cần trích xuất: 12345
Regex nào đúng?
A. href="(.*?)"
B. /profile/(\d+) ✅
C. <h1>(.*?)</h1>
D. \d+
👉 Đáp án: B (match chính xác số trong URL).
Câu 3 – XML Response
Response:
Cần trích xuất: TXN5566778899
Regex nào đúng?
👉 Đáp án: A .
Câu 4 – Header Response
Header:
Cần trích xuất: qwerty123abc
Regex nào đúng?
A. SESSIONID=(.*?); ✅
B. Set-Cookie: (.*?)
C. Path=(.*?)
D. SESSIONID=(.*)
👉 Đáp án: A .
Câu 5 – Body Text
Response:
Cần trích xuất: ORD2025001
Regex nào đúng?
A. #(.*?)\.
B. ORD\d+
C. order ID is #(.*?)\.
D. #ORD(\d+) ✅
👉 Đáp án: D (match ORD + số, loại bỏ ký tự #).
5. Kết luận & Bài tập thêm
Regular Expression Extractor là công cụ quan trọng trong JMeter để xử lý dữ liệu động.
Nên luyện tập với nhiều loại response: JSON, HTML, XML, Header, Body text.
Thực hành với Match No. = -1 để lấy nhiều giá trị cùng lúc.
With over 4 years of experience in software testing — including manual, automation, and performance testing — I have built a strong foundation in delivering high-quality software.
I specialize in the E-commerce and Banking domains, with deep understanding of business flows, performance requirements, and testing standards.
Strong in critical thinking and problem-solving , I proactively identify issues and drive effective solutions.
With an engineering mindset , I continuously update my skills and contribute across functions to help teams achieve their goals.
Chia sẻ khóa học lên trang
Bạn có thể đăng khóa học của chính bạn lên trang
Anh Tester để kiếm tiền