Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex to match non integers?

Trying to create a regex that ignores a proper integer (1, 5, 999, etc.) and forward slashes (/), but finds a match in everything else. For example, it would find a match the following:

  • test
  • test1
  • test-1

but ignores

  • 1
  • 55
  • 7

This is for a mod rewrite.

like image 555
Manny Fleurmond Avatar asked Oct 19 '25 23:10

Manny Fleurmond


1 Answers

[^-0-9\/]+ should do the trick, I think. It'll match any string that contains a non-digit.

Edited to add minus sign which would also be allowed in an integer, and then to include the forward slashes mentioned in the question.

like image 163
Ben Hocking Avatar answered Oct 22 '25 03:10

Ben Hocking



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!