0

I'm still learning PHP regular expressions. I need a help from returning a matches at once, from bellow provided strings. I need a date (between brackets) and status (Registered/Reachable):

[Feb 28 13:22:37] VERBOSE[1111] chan_sip.c:     -- Registered SIP \'1001\' at 127.0.0.1:8080
[Feb 28 13:22:37] NOTICE[1111] chan_sip.c: Peer '1001' is now Reachable. (471ms / 2000ms)
Qtax
  • 33,241
  • 9
  • 83
  • 121
Nikola Ristivojevic
  • 169
  • 1
  • 3
  • 12
  • 2
    What have you tried? So your example text has two entries and you need both of them? Can you explain a little bit more about what you mean by getting the status? – Adam Plocher Mar 10 '13 at 20:38
  • 1
    Where did your attempts fail specifically? (While you say you're learning them, most of these regex-please-help-me questions are coding requests, hence the inquiry if you at least tried yourself). * See also [Open source RegexBuddy alternatives](http://stackoverflow.com/questions/89718/is-there) and [Online regex testing](http://stackoverflow.com/questions/32282/regex-testing) for some helpful tools, or [RegExp.info](http://regular-expressions.info/) for a nicer tutorial. – mario Mar 10 '13 at 20:38

1 Answers1

2

You could use this:

/^\[([^\]]+)\].*(Registered|Reachable)/

Group 1 and 3 have your date and status.

Daedalus
  • 1,667
  • 10
  • 12