# How to Ignore Cast Errors

**URL:** <https://community.exasol.com/t/how-to-ignore-cast-errors/169>\
**Category:** Help Needed\
**Created:** [June 6, 2025, 3:26pm UTC](https://community.exasol.com/t/how-to-ignore-cast-errors/169 "2025-06-06T15:26:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Exa101](https://avatars.discourse-cdn.com/v4/letter/e/3ec8ea/32.png) [@Exa101](https://community.exasol.com/u/Exa101)\
**Post date:** [June 6, 2025, 3:26pm UTC](https://community.exasol.com/t/how-to-ignore-cast-errors/169/1 "2025-06-06T15:26:56Z")

</div>

Hi,

I was trying to cast a string to number but got an error since the field contained some non-numeric characters or where null.  
I had to extract the integer through regular expression to get it to work. Is there any other way to use regular cast and just ignore all unsucceful tries?

> TO\_NUMBER(REGEXP\_SUBSTR(strNumber,‘[0-9]\*’))

---

<div class="post-metadata">

**Author:** ![Vitalii\_Shilin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.exasol.com/vitalii_shilin/32/35_2.png) [@Vitalii\_Shilin](https://community.exasol.com/u/Vitalii_Shilin)\
**Post date:** [June 6, 2025, 5:49pm UTC](https://community.exasol.com/t/how-to-ignore-cast-errors/169/2 "2025-06-06T17:49:41Z")

</div>

You might want to give a try to our family of IS\_% functions:

```auto
with  
to_clean(col1) as(  
	SELECT  
		*  
	from  
		values ('1'), ('1a'), ('2.5'), ('3,6')  
)  
select  
	tc.col1  
	, case  
		when is_number(tc.col1) then to_number(tc.col1)  
	end as col1_num  
from  
	to_clean tc  
;  
/*  

COL1|COL1_NUM|  
----+--------+  
1 | 1.0|  
1a | |  
2.5 | 2.5|   
3,6 | |  
*/  

```
