এই নিবন্ধে আমরা C++ STL-এ match_results::prefix() এবং match_results::suffix() ফাংশনের কাজ, সিনট্যাক্স এবং উদাহরণ নিয়ে আলোচনা করব।
C++ STL-এ ম্যাচ_ফলাফল কী?
std::match_results হল একটি বিশেষ ধারক-সদৃশ শ্রেণী যা অক্ষর ক্রমগুলির সংগ্রহ ধরে রাখতে ব্যবহৃত হয় যা মিলে যায়। এই কন্টেইনার ক্লাসে একটি রেজেক্স ম্যাচ অপারেশন লক্ষ্য ক্রমের মিল খুঁজে পায়।
match_results কি::prefix()?
match_results::prefix() ফাংশন হল C++ STL-এ একটি অন্তর্নির্মিত ফাংশন, যা
সিনট্যাক্স
match_results.prefix();
পরামিতি
এই ফাংশন কোন প্যারামিটার গ্রহণ করে না।
রিটার্ন মান
এই ফাংশনটি স্ট্রিং বা ম্যাচ সিকোয়েন্সের আগের ক্রমটির ধ্রুবক রেফারেন্স প্রদান করে।
উদাহরণ
Input: string str = "Tutorials Points";
regex R("Points");
smatch Mat;
regex_search(str, Mat, R);
Mat.prefix();
Output: Tutorials উপসর্গ()
উদাহরণ
#include <bits/stdc++.h>
using namespace std;
int main() {
string str = "Tutorials Points";
regex R("Points");
smatch Mat;
regex_search(str, Mat, R);
cout<<"String prefix is : ";
if (!Mat.empty()) {
cout << Mat.prefix();
}
return 0;
} আউটপুট
যদি আমরা উপরের কোডটি চালাই তবে এটি নিম্নলিখিত আউটপুট −
উৎপন্ন করবেString prefix is : Tutorials
match_results কি::suffix()?
match_results::suffix() ফাংশন হল C++ STL-এ একটি অন্তর্নির্মিত ফাংশন, যা
সিনট্যাক্স
match_results.suffix();
পরামিতি
এই ফাংশন কোন প্যারামিটার গ্রহণ করে না।
রিটার্ন মান
এই ফাংশনটি স্ট্রিং বা সিকোয়েন্সের ধ্রুবক রেফারেন্স দেয় যা ম্যাচ সিকোয়েন্সের পরে।
উদাহরণ
Input: std::string str("Tutorials Points is the best");
std::smatch Mat;
std::regex re("Points");
std::regex_match ( str, Mat, re );
Mat.suffix();
Output: is the best প্রত্যয়()
উদাহরণ
#include <bits/stdc++.h>
using namespace std;
int main() {
string str = "Tutorials Points is the best";
regex R("Points");
smatch Mat;
regex_search(str, Mat, R);
cout<<"String prefix is : ";
if (!Mat.empty()) {
cout << Mat.suffix();
}
return 0;
} আউটপুট
যদি আমরা উপরের কোডটি চালাই তবে এটি নিম্নলিখিত আউটপুট −
উৎপন্ন করবেString prefix is : is the best