I'm reading line by line and making comparisons. I have been using the index function but I knew what my substring was. Now I don't know what my substring is. I have an index function searching for ' /* ' and as soon as I see this comment, I want to know if there is anything before it on the line.
For example:
-
print "hello"; /* prints hello */
-
I'm trying to determine if there is a line of code before the comment starts. Now I have this approach done by searching for a semicolon. Then comparing the index of the semicolon to the index of /* and checking if the index of the semicolon is lower than the the index of the /* which means that there is a line of code. Now I have this problem what if there is no semicolon there such as
print "hello" /* prints hello */
;
This line of code will still execute but I will not know if there is something before the /*. My question is, is there someway of reading the first character in the line and comparing that to / to determine if there is something before the /*
Psuedocode:
-
if (index($_, "/*"))
-
{
-
#now check to see if there is something before it
-
-
if(first character of line == "/")
-
{
-
print "yes there is something before /* ";
-
}
-
-
}
-
Any help would be greatly appreciated. Thanks in advance. In the meantime I will continue to look for a solution. If I find one, I will post the answer.