-1

I have this set of data:

  • EndDate":"2024-10-24","Employee":"000A0001","Submitted":"N"
  • EndDate":"2023-10-18","Employee":"000A0001","Submitted":"P"
  • EndDate":"2021-01-02","Employee":"000A0001","Submitted":"J"
  • EndDate":"2022-10-11","Employee":"000A0001","Submitted":"M"
  • EndDate":"2020-09-18","Employee":"000A0001","Submitted":"N"

I only want to capture the EndDate that has a Submitted value of N or M.

The captured EndDate should be:

  • 2024-10-24
  • 2022-10-11
  • 2020-09-18
tirador
  • 1
  • 1

2 Answers2

0

Yes, you can do this with a regex positive lookahead:

\d{4}-\d{2}-\d{2}(?=.+"Submitted":"[NM]")

More detail here: Regex lookahead, lookbehind and atomic groups

jdaz
  • 5,964
  • 2
  • 22
  • 34
0

Capture the date and use a look ahead:

"EndDate":"([^"]+)"(?=.*"Submitted":"[NM]")

You enddates are in group 1 of the match.

Note: I added '"' to the start of the regex assuming that you accidentally omitted it from the examples that appear to be json.

Bohemian
  • 412,405
  • 93
  • 575
  • 722