Message 1 of 8

Not applicable
06-13-2021
06:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm looking for a function to get the position of the last numeric character in an alphanumeric string. I found one from Lee_Mac below but it's for the first number in a string and I'm what I'm after is for the last numeric character.
(defun numpos ( str )
(if (wcmatch str "*#*")
(- (strlen str) (length (vl-member-if '(lambda ( x ) (< 47 x 58)) (vl-string->list str))))
)
)
"This is a sample string with numbers like 0, 1, 2.5, 3a, 4.04 and 5.06 and some other symbols such as *, #, (,) etc."
So, based from the above example, I'm looking for the position of the last numeric character which is 6 and the string is not constant. Thanks.
Solved! Go to Solution.