1

I created the regex below:

/(.*) \(...\) (.*)/g

And in regex101 the groups that I need to retrieve works.

But when I try to use this regex in my javascript code it returns the full match.

Here is the example:

"No rasto de Magalhães, (...) sua brincadeira profilática"

To the sentence above, It should have returned an array with 2 matches, but my js code returns the entire sentence:

["No rasto de Magalhães,", "sua brincadeira profilática"]

This is my js code to match the string occcurence:

var occurrenceHasSeparator = occurrence.match(/(.*) \(...\) (.*)/g);

Does anyone has any tips? Thanks in advance!

EDIT

It is not a duplicate, I know how to access the group values. It returns an array with the group matches. The problem here is that my regex is returning an array with the full sentence instead of two values.

Toto
  • 89,455
  • 62
  • 89
  • 125
Gabriel Mesquita
  • 2,271
  • 1
  • 20
  • 30

0 Answers0