
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Replace Special characters in Deicmal Values
Hi Team
I am i have a string valuue like 1500.00- here i want to get 1500.00
Means any special character other than . should be removed. can you please help me out with this
I am tried with replaceAll("[^\\D.]+", "") but getting wrong results.
Thanks
Deepthi
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This one should be enough:
row1.yourField.replaceAll( "[^\\d.]", "" )
For the following sample data:
1000 100.5 500- 10.3@#$%
the result is:
[statistics] connecting to socket on port 3843 [statistics] connected .---------. |tLogRow_52| |=-------=| |yourField| |=-------=| |1000 | |100.5 | |500 | |10.3 | '---------' [statistics] disconnected
To convert the result to BigDecimal, just do that:
new BigDecimal(row1.yourField.replaceAll( "[^\\d.]", "" ))
This can be achieve in your tMap or tJavaRow for example.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@SaranyaKatakam,can you use the below to convert sting to Double using any one.should fix your issue.
Double.parseDouble(row3.newColumn1.replaceAll("-", ""))
Double.parseDouble(row3.newColumn1.replace("-", ""))

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Thanks for you replay
Not only "-" i want to remove any special character like @#$% etc other than "." and convert it to big decimal
Thanks
Deepthi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This one should be enough:
row1.yourField.replaceAll( "[^\\d.]", "" )
For the following sample data:
1000 100.5 500- 10.3@#$%
the result is:
[statistics] connecting to socket on port 3843 [statistics] connected .---------. |tLogRow_52| |=-------=| |yourField| |=-------=| |1000 | |100.5 | |500 | |10.3 | '---------' [statistics] disconnected
To convert the result to BigDecimal, just do that:
new BigDecimal(row1.yourField.replaceAll( "[^\\d.]", "" ))
This can be achieve in your tMap or tJavaRow for example.
