+ Start a Discussion
Radhe Shyam.Radhe Shyam. 

How to insert space between two characters

How to insert space between two characters?
I have:
String s = '(1 OR 2) AND 3';
I need to insert spcae between ( and 1 ;   and between 2 and ) ;so that final string should be s = '( 1 OR 2 ) AND 3'

Please help.
Best Answer chosen by Radhe Shyam.
Anand Sharma 35Anand Sharma 35
String s='(1 OR 2) AND 3';
s=s.replace('(','( ').replace(')',' )');