Skip to main content
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
tresesco
MVP
MVP

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

 

tresesco
MVP
MVP

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

tresesco
MVP
MVP

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

tresesco
MVP
MVP

So the smarter solution is here. 🙂