Replace string java Scanner class?

Try String strOutput = inString. ReplaceAll("\\bis\\b","was") reference link Test output: Input String: is island is feris kiss output was island was feris kiss.

Try String strOutput = inString. ReplaceAll("\\bis\\b","was"); reference link Test output: Input String: is island is feris kiss output was island was feris kiss.

– Mark Elliot Mar 26 at 20:13 @Mark it seems to be fine for the test cases you mention. – Bala R Mar 26 at 20:16 The trailing \\b wasn't there when I commented, now I agree, +1 – Mark Elliot Mar 26 at 20:17 what does \\bis\\b indicate, I know be is the boundary value – user665319 Mar 26 at 22:24.

Not that I know much with java, but you can try adding spaces. Theoretically that should work. System.out.

Println("Input String:\n"); Scanner keyboardScanner = new Scanner(System. In); String inString = keyboardScanner.nextLine(); String strOutput = inString. Replace(" is "," was "); System.out.

Println(strOutput).

– Mark Elliot Mar 26 at 20:16 I tried that already before posting the question but then what if the first occurence of the sentence is "is" with no space before it. In that case this first occurence3 is never replace because it does not match "is " – user665319 Mar 26 at 20:39.

String strOutput = inString. Not that I know much with java, but you can try adding spaces. Theoretically that should work.

String strOutput = inString. Terms of service. Not the answer you're looking for?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions