I have to find a pattern in a string and only keep the middle part if the pattern matches.
The pattern is below:
(space)(↳)(space)(any characters, numbers symbols etc)(space)(-)(space)(currency symbol, could be £$ etc)(1 or many digits)(.)(2 digits)
↳ Add milk - £0.25
If the pattern matches I want to keep (any characters, numbers symbols etc) and discard everything else.
Is it possible?
()in your regex to denote sub-matches. When you run.exec(), the results will contain these sub-matches. Details here: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…