Regex for everything before -

What should be the Regex to get everything after and before the “-”?
Input: 3:09 PM - 6:08 PM
A regex to get
3:09 PM
and another one to get
6:08 PM

Isn’t there a split-command in JS? I know there is one in Python…
Anyway for RegEx, you’d need to use “lookahead” and “lookbehinds”. Should be straightforward to google.

Have you tried out WildCard(.) or Dot(.) any of the name you understand

Solution:

  const time = "3:09 PM - 6:08 PM"
  const firstTimeValue = time.split('-').shift()
  const secondTimeValue = time.split('-').splice(1).join('-')

Have you encountered “Array destructuring” yet? That could be useful here:

const time = "3:09 PM - 6:08 PM";
const [start, end] = time.split(" - ");