Login  Register

Re: Replace part of string help

Posted by Nathaniel Ryckman on Jul 29, 2011; 4:50pm
URL: http://imagej.273.s1.nabble.com/Replace-part-of-string-help-tp3683695p3683696.html

System.out.print(name.replace("(Seq.Scan)",""));

There is no reason to use regular expressions for something so simple. Also, you could make the replace function from scratch, but why bother when someone has already included that functionality into the String class?

Dr Adam Cliffe wrote
Hi,

I'm trying to remove part of a file name.
Current file name is : "Job(Seq.Scan) 2 02_024_z0_ch01.tif"
I'd like to remove the (Seq.Scan) part.

using the following macro I end up with: Job() 2 02_024_z0_ch01.tif

name = "Job(Seq.Scan) 2 02_024_z0_ch01.tif";
string=replace(name,"(Seq.Scan)","");
print(name);

Can anyone help getting rid of the brackets please?

thanks

Adam


Dr Adam Cliffe
Research Scientist, Rorth Lab

Institute of Molecular and Cell Biology
61 Biopolis Drive
Proteos
Singapore 138673

tel: +65 6586 9731