Say i have a file which contains lines as follows:
Hayden y Suppose i want to manipulate the line which only contains "y" and not the one with Hayden, how would i do this?
So i read in the file and parse it line by line. I want to say if the line contains letters before or after "y" then it's not the line i'm looking for.
I thought i could do the following:
String value = "y"; if(strLine.matches("[a-zA-Z]" + value + "[a-zA-Z]")) { don't manipulate line here } else { manipulate string here } However, this gets "Hayden" as well as "y"
Any ideas?
EDIT
sorry, i should have been more clear, what if i don't mind if there are spaces or symbols in front? or behind? it's specifically the letters that i need to watch out for. For instance, i can't have yh but i can have y=... sorry again