Wednesday 15 July 2015

regex - Trim a string between two delimiters -


I have a number string, for example 14569 927-4332-1 1902. I want to trim it first with '-' from delimiter to the next '-' delimiter. As a result only: '4332'

I tried this reggae: (^ - [0- 9]) but I am not perfect.

How do I get this string from '4332'?

Thanks & amp; A good weekend!

some options ...

Awk :

  $ string = '14569 927-4332-119-02' $ awk -F- '{print $ 2}' & lt; & Lt; & Lt;  {String # * -} $ resonant "$ string" 4332   

cut : $ cut -d'- ' -f2 & lt; & Lt; & Lt; "$ String" 4332

No comments:

Post a Comment