sajad torkamani

General pattern

/^-?\d+$/

JavaScript example

function isValidInteger(value) {
  return /^-?\d+$/.test(value)
}

// isValidInteger(50) // true
// isValidInteger(-30) // true
// isValidInteger(--10) // false
// isValidInteger (-6-10) // false

Tagged: Regex

Leave a comment

Your email address will not be published. Required fields are marked *