I'm creating a plugin that edits scripts for me, and I was wondering how to find out if a number is a string or an actual number? (e.g "2" or 2) Whenever I use typeof() it returns string only for the source, how do I check if the number is part of a string or not?
Given a string you must find numbers in, you can use string patterns. Specifically, you can use the %d+
pattern, which matches digits with the %d
character class, and one or more of them with the +
quantifier.
To check if there is a string, we can use string.find(string, "%d+")
.
Helpful resources: