My javascript regex is unreliable -


this regex i'm using

.match(/\[(.*)\]\s*([^\s]+)\s*([^\s]+)\s*(.*)/) 

and fails capture timestamp when there close square bracket

[2016-01-22 22:14:58,098] warn  service.catalog.mediacontroller  - foo1 foo foo foo foo foo [2016-01-22 22:14:58,235] warn  service.catalog.mediacontroller  - foo2 foo foo foo foo foo]; sdfd sf sd [2016-01-22 22:14:58,240] info  service.catalog.restapicontroller  - foo3 foo foo foo] foo foo [2016-01-22 22:14:58,259] info  service.catalog.dynamicroutingcontroller  - foo4 foo foo foo foo foo [2016-01-22 22:14:58,457] error service.catalog.basecontroller  - foo5 foo foo foo foo foo 

try this:

^\[(.*?)\] 

demo - regex101


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -