Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
tal_barnea
Contributor
Contributor

Finding the index of the first non-numeric character

I'm trying to find the index of the first non-numeric character in a string.

If I wanted to find the first numberic one, I'd use FindOneOf( my_string, '0123456789')

My questions are:

1. Is there already a "system" charset that defines all numeric and/or all non-numeric characters? Or do I have to define ones myself?

2. Is there a way to ask for an "alternative" charset in FindOneOf, meaning, find any character which isn't part of the set I entered?

Thanks a bunch!

Tal.

Labels (1)
5 Replies
tresB
Champion III
Champion III

I would try like (until someone gets a smarter solution 🙂)

=Index(
Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace('12309$BNV', '1', '0'), '2','0'), '3','0'), '4','0'), '5','0'),'6','0'),'7','0'),'8','0'),'9','0')
,'0',-1)+1

 

Note: Highlighted string is your input string

 

tresB
Champion III
Champion III

Wait!.. this is still not correct. This wouldn't work where numbers are there in the middle of the string. Let me correct it.

tresB
Champion III
Champion III

I guess this should work.

=Len('1230955$BNV988')-
Len(ltrim(
Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace('1230955$BNV988','0',' '), '1', ' '), '2',' '), '3',' '), '4',' '), '5',' '),'6',' '),'7',' '),'8',' '),'9',' ')
))+1

MarcoWedel

Hi,

another solution might be to purge the numerics from your string using the remainder as characters to search for, i.e. what's left can be found by the FindOneOf() function as well:

 

=FindOneOf('486838SomeText389734958',PurgeChar('486838SomeText389734958','0123456789'))

 

 

hope this helps

Marco

tresB
Champion III
Champion III

So the smarter solution is here. 🙂