G
GRecken
Is it just me or is this very confusing????
All I want to do is to take a string and do a search and replace.
My string will look something like:
fdafsadfs[!!!VALUE]fdklajdkljafkldjlkfajslksd
And I want to find the [!!!VALUE] and replace it with the value from the database.
My code is very skimpy and far from close.
**********
String str1 = "fda!fsadfs[!!!VALUE]fdklajdkljafkldjlkfajslk!sd"
Pattern p = Pattern.compile("[!!!(.*?)]");
String newStr = t1.replaceAll( p.pattern(), "NEWVALUE" );
*********************
But this replaces all of the "!" with "NEWVALUE" which results in:
fdaNEWVALUEfsadfs[NEWVALUENEWVALUENEWVALUEVALUE]fdklajdkljafkldjlkfajslkNEWVALUEsd
Can anyone please point me in the right direction?
Thanks,
Greg
All I want to do is to take a string and do a search and replace.
My string will look something like:
fdafsadfs[!!!VALUE]fdklajdkljafkldjlkfajslksd
And I want to find the [!!!VALUE] and replace it with the value from the database.
My code is very skimpy and far from close.
**********
String str1 = "fda!fsadfs[!!!VALUE]fdklajdkljafkldjlkfajslk!sd"
Pattern p = Pattern.compile("[!!!(.*?)]");
String newStr = t1.replaceAll( p.pattern(), "NEWVALUE" );
*********************
But this replaces all of the "!" with "NEWVALUE" which results in:
fdaNEWVALUEfsadfs[NEWVALUENEWVALUENEWVALUEVALUE]fdklajdkljafkldjlkfajslkNEWVALUEsd
Can anyone please point me in the right direction?
Thanks,
Greg