0

How can I create a Lookbehind expression matching on a dynamic pattern? In other words, the text pattern I am trying to match in the Lookbehind statement should also be pattern matched. Example below:

I have the text:

Last flapped : 2018-05-18 07:11:06 CEST (12w3d 11:08 ago)

And I want to match the date and time after "Last flapped :". The only problem is that the number of spaces between "flapped" and the ":" can vary.

41686d6564
  • 15,043
  • 11
  • 32
  • 63
  • You probably want to look into quantifiers like `*` and `+`. See the **Quantifiers** section of [this post](https://stackoverflow.com/a/22944075/3600709). Also, specify the language you are using or regex engine/flavour and post your current pattern and the result you'd like to achieve. – ctwheels Aug 13 '18 at 18:29
  • [Like this?](https://regex101.com/r/4w7QiK/1) – emsimpson92 Aug 13 '18 at 18:29
  • Looks like you meant Lookbehind, _not Lookahead_? Anyway, you can use a capturing group instead: [`Last flapped \s*:\s*(\d{4}-\d{2}-\d{2})`](https://regex101.com/r/OWRwEg/1). – 41686d6564 Aug 13 '18 at 18:30
  • @AhmedAbdelhameed thank you, that works perfectly. And yes, Lookbehind :-) –  Aug 14 '18 at 08:20

0 Answers0