Skip to main content
reedit
Source Link
Satyam Pathak
  • 7k
  • 3
  • 28
  • 52

// Change of the text for better test results var subject = "This"hjavsdghvwh isjgya a16162vjgahg451514vjgejd5555v testfhgv messagef [REF:262641hvgf 2323232]";665115bs cj15551whfhwj511"; var regex = /\d+/g; let number = subject.match( regex ) console.log(number)

It Will return array for now, and if no match found, it will return null. For most of the time, when i used this regex i get perfect result unless if string contains decimal values.

var subject = "This is a test message [REF: 2323232]"; var regex = /\d+/g; let number = subject.match( regex ) console.log(number)

It Will return array for now, and if no match found, it will return null

// Change of the text for better test results var subject = "hjavsdghvwh jgya 16162vjgahg451514vjgejd5555v fhgv f 262641hvgf 665115bs cj15551whfhwj511"; var regex = /\d+/g; let number = subject.match( regex ) console.log(number)

It Will return array for now, and if no match found, it will return null. For most of the time, when i used this regex i get perfect result unless if string contains decimal values.

Source Link
Satyam Pathak
  • 7k
  • 3
  • 28
  • 52

var subject = "This is a test message [REF: 2323232]"; var regex = /\d+/g; let number = subject.match( regex ) console.log(number)

It Will return array for now, and if no match found, it will return null