-1

I have a requirement to capture the ',' separated values which are the following pattern XXXX.XXXX,XXX.XXX the max digits are 4 on both side of the '.'

thanks

RamMohan222
  • 113
  • 1
  • 7
  • 2
    What's your question? Where's the effort? What have you tried so far? – Blue Sep 28 '18 at 05:28
  • It seems you are looking for [`String.prototype.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) method. – Ram Sep 28 '18 at 05:29
  • I think you need `if (s.test(/^\d{1,4}\.\d{1,4}(?:,\d{1,4}\.\d{1,4})*$/)) { alert("Correct!"); }`, see [demo](https://regex101.com/r/mIQf7U/1). – Wiktor Stribiżew Sep 28 '18 at 13:40

1 Answers1

0

Here's a better one:

(?:^|,)(\d{1,4}\.\d{1,4})(?=,|$)

Pushpesh Kumar Rajwanshi's solution has some issues. For the following pattern

13456.1234,433.544

It would output this:

3456.1234
WofWca
  • 571
  • 3
  • 11