troubleshooting Question

plusOut java challenge

Avatar of gudii9
gudii9Flag for United States of America asked on
ProgrammingJavaJava App ServersJava EERegular Expressions
40 Comments4 Solutions607 ViewsLast Modified:
I am working on below challenge
I tried my code as below
public String plusOut(String str, String word) {
return str.replaceAll(".word.","+word+");
I am getting below result
Expected      Run            
plusOut("12xy34", "xy") → "++xy++"      "12xy34"      X         
plusOut("12xy34", "1") → "1+++++"      "12xy34"      X         
plusOut("12xy34xyabcxy", "xy") → "++xy++xy+++xy"      "12xy34xyabcxy"      X         
plusOut("abXYabcXYZ", "ab") → "ab++ab++++"      "abXYabcXYZ"      X         
plusOut("abXYabcXYZ", "abc") → "++++abc+++"      "abXYabcXYZ"      X         
plusOut("abXYabcXYZ", "XY") → "++XY+++XY+"      "abXYabcXYZ"      X         
plusOut("abXYxyzXYZ", "XYZ") → "+++++++XYZ"      "abXYxyzXYZ"      X         
plusOut("--++ab", "++") → "++++++"      "--++ab"      X         
plusOut("aaxxxxbb", "xx") → "++xxxx++"      "aaxxxxbb"      X         
plusOut("123123", "3") → "++3++3"      "123123"      X         
other tests

how to  improve my approach, results and design of this challenge. How do i make a graphical venn or flow chart or some other relevant diagram to design it before writing code to decide best strategy?
 Please advise
Join our community to see this answer!
Unlock 4 Answers and 40 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 4 Answers and 40 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros