regex - Grep not catching the whole pattern -


the pattern want out this: city followed pointing arrow either direction ( -> or <- ) followed city , followed pointing arrow.

i figured, maybe because didnt escape of character, tried escaping them, , didnt desired result.

i run command:

grep -o  '(\|stockholm\|paris\|tokyo){1}[<->]{2}(\|stockholm\|paris\|tokyo){1}[<->]{2}' 

on text data :

tokyo->paris->$nill1110102.8 fubar$`blackfri$$$sunbluepurpleoct011001sun3.1415 sun[<-->]0000103.14011010taonill$101101010001`3.14153$$$$$$phiparis->paris-> paris<-tokyo<-redorange 2.8void'$$[<-->]000010whitestockholm->stockholm->white2.8taosunwhitephifooblah frinilltao`paris<-tokyo<-whitevoidnullorange101000phifubaroct$voidmon'[<-<-]$$  001100blah[<-<-]stockholm->paris->fubarfubar'febyellow[<-->]novnull011001white`$ 

the grep command ive written indeed select citys, not pointing arrows, wonder why , if can shed light me.

thanks.

edit: please dont come diffrent solutions using sed or perl or whatever, wish learn error here, thanks.

output get:

paris paris paris stockholm stockholm paris stockholm paris 

desired output;

stockholm->stockholm-> paris<-tokyo<- stockholm->paris-> 

i think want?

grep -eo '(stockholm|paris|tokyo){1}[<>-]{2}(stockholm|paris|tokyo){1}[<>-]{2}' jozo tokyo->paris-> paris->paris-> paris<-tokyo<- stockholm->stockholm-> paris<-tokyo<- stockholm->paris-> 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -