Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can a string.match include decimal points?

Tags:

string

lua

So I am trying to get string.match to not only get '%d+'(any string of strait digits) but I want it to include decimal points IF they are present. I can't make the pattern '.%d+' or '%d+.%d+' because then those would detect any punctuation and wouldn't get a plain non decimal number

I'm so lost here

like image 458
Citre Ithkarr Avatar asked Aug 06 '26 17:08

Citre Ithkarr


1 Answers

Try the pattern "(%d*%.?%d+)"

It matches:

  • 12345
  • 12.345
  • .12345

But not:

  • 12345.
like image 119
daurnimator Avatar answered Aug 08 '26 09:08

daurnimator



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!