Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Find and replace a pattern in a String

 
Aditya Sirohi
Ranch Hand
Posts: 93
Eclipse IDE Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,


I want to replace "|DEPLOYDIR|" expression in the string test.

String test = "cmd /c start /wait |DEPLOYDIR|\\setup";
test = test.replaceAll("|^DEPLOYDIR|$", "testvalue"); --> does not seem to work!!

I want an output like:
cmd /c start /wait testvalue\\setup

How can i do this??

-Adi
 
Winston Gutkowski
Bartender
Pie
Posts: 10527
64
Eclipse IDE Hibernate Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aditya Sirohi wrote:I want an output like:
cmd /c start /wait testvalue\\setup
How can i do this??

Did you try
test = test.replace("|DEPLOYDIR|", "testvalue");
?

Sometimes you can overthink things

Winston
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic