Validation of matching comments
-
Hi i want to validate the matching comments.(/* */).Every file should start with the /* and should end with */. if he gives multiple comments it sholud not be validate. Here iam showing some possible example which user may enter. 1./*text*//* 2./*text*/*/ 3./*text/**/ but that should be only /*text*/.other than this situation i need to throw an error.he is entering the file in edit box. please any one can give me the solution for this problem.
-
Hi i want to validate the matching comments.(/* */).Every file should start with the /* and should end with */. if he gives multiple comments it sholud not be validate. Here iam showing some possible example which user may enter. 1./*text*//* 2./*text*/*/ 3./*text/**/ but that should be only /*text*/.other than this situation i need to throw an error.he is entering the file in edit box. please any one can give me the solution for this problem.
Load the file into memory and use the boost::RegEx class to validate it. For more information, check out boost.org.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
-
Hi i want to validate the matching comments.(/* */).Every file should start with the /* and should end with */. if he gives multiple comments it sholud not be validate. Here iam showing some possible example which user may enter. 1./*text*//* 2./*text*/*/ 3./*text/**/ but that should be only /*text*/.other than this situation i need to throw an error.he is entering the file in edit box. please any one can give me the solution for this problem.
-
Hi i want to validate the matching comments.(/* */).Every file should start with the /* and should end with */. if he gives multiple comments it sholud not be validate. Here iam showing some possible example which user may enter. 1./*text*//* 2./*text*/*/ 3./*text/**/ but that should be only /*text*/.other than this situation i need to throw an error.he is entering the file in edit box. please any one can give me the solution for this problem.
Search for '/*' in the file. It should be found only once and the offset should be 0. Then search for '*/' in the file. Again this should be found only once and offset should be at end of file.
reddy harish wrote:
he is entering the file in edit box
I assumed you have access to the file contents in a string so you can use string::find
---------------------- Mayank Thakore Learning C++ - since 1998 They didn't print my card right; so I resigned.
-
Hi i want to validate the matching comments.(/* */).Every file should start with the /* and should end with */. if he gives multiple comments it sholud not be validate. Here iam showing some possible example which user may enter. 1./*text*//* 2./*text*/*/ 3./*text/**/ but that should be only /*text*/.other than this situation i need to throw an error.he is entering the file in edit box. please any one can give me the solution for this problem.
I dont think that it would require any special programming. Whenever you get a /*, you will have to search for a */. If you get any /* nested inside a /*, then you will have to ignore it. Set a flag to indicate that you have already got a /*, then ignore subsequent /* while the flag is on. When you get a */, just put off the flag and consider the whole part as a commented area. Hope it helps.
*** Who said nothing is impossible? I have been doing it for a long time ***
-
I dont think that it would require any special programming. Whenever you get a /*, you will have to search for a */. If you get any /* nested inside a /*, then you will have to ignore it. Set a flag to indicate that you have already got a /*, then ignore subsequent /* while the flag is on. When you get a */, just put off the flag and consider the whole part as a commented area. Hope it helps.
*** Who said nothing is impossible? I have been doing it for a long time ***
I don't think it will be quite that simple. For example what happens if a "//", "/*" or "*/" is inside quotes?
Steve
-
I don't think it will be quite that simple. For example what happens if a "//", "/*" or "*/" is inside quotes?
Steve
well, steve, what i suggested was the simplest way and the basic algorithm. If the need of checking inside strings is required, then it could very well be checked too. There could be several other requirements too. All of them could be simply built over that basic algo.
*** Who said nothing is impossible? I have been doing it for a long time ***