regex - Auto-clean Log Formats -


i've run several different situations need implement "log cleanup" regex. i've had re-implement couple times, basic variant this:

the original

(23:59:59) username says: user inputted text (00:00:13) username user inputted action (00:01:42) username says: user inputted text (00:02:13) username says: user inputted text 

i'm looking lookahead/lookbehind regex converts to:

(23:59:59) username says: user inputted text (00:00:13) username user inputted action  (00:01:42) username says: user inputted text (00:02:13) username says: user inputted text 

what's angle of attack, , why?

unless regex absolutely necessary,

awk '/^\(/{print ""}{printf "%s ",$0}' file 

the logic behind print lines without newline, except when "(" encountered first character. can implemented in language.

bash

#!/bin/bash  while read -r line  case "$line" in    "("* ) echo  esac  printf "%s " $line done<"file" 

Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -