Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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

Labels (2)
1 Solution

Accepted Solutions
TRF
Champion II
Champion II

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.

 

 

 

View solution in original post

3 Replies
manodwhb
Champion II
Champion II

@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("-", ""))

Anonymous
Not applicable
Author

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

TRF
Champion II
Champion II

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.