Click here to Skip to main content
15,894,410 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C++
#include<iostream>
#include<regex> 
#include<string.h> 
using namespace std;
void main()
{
	string E1 ;
	cout << "Enter a sentence E1 : " << endl;
	getline(cin, E1);

	regex r("\\[+ [a-z]*||([A-Za-z]*||(\\[+\\] )+\\, +\\]");
	bool b = regex_match(E1, r);

	cout <<( b ? "T":"f")<< endl;
	system("pause");
}

input: [A,nana,12,[],[as,45,Ad]] 
output:match


and I want to split it to get header,tail and sub using c++.
Posted
Updated 15-Dec-15 17:29pm
v5
Comments
Sergey Alexandrovich Kryukov 15-Dec-15 15:02pm    
I don't think you defined a problem. A sample/example is not the definition, but even your example is unclear. What should match what? What's on input and what should be on output? What makes you thinking that this is a suitable task for Regular Expressions?
—SA
Mohibur Rashid 15-Dec-15 19:22pm    
did you try google? anyway, try this link

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900