Solved

regex pattern help - can't get a grep "regex" file to work.

Posted on 2006-11-08
2
321 Views
Last Modified: 2010-04-21
I am trying to make retrieve a regex pattern. I would like to retrieve a pattern of 1-3 digits followed by a colon followed by the same again.

For example:
$ cat test.txt
1:2:
13:26:
3:26:
333:26:
36:6:
333:263:

I would like to have all these patterns printed.
Here is what I get:
$ grep -e '\d{1,3}:d{1,3}:' test.txt
~/tmp $  

Nothing.

I will also have to be printing the same pattern with a space before and after in another file.  I have been using:
grep -e '\s\d{1,3}:d{1,3}:\s' test.txt
without success.

Any help appreciated.

Thanks,
ibanja

0
Comment
Question by:ibanja
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 58

Accepted Solution

by:
amit_g earned 250 total points
ID: 17899717
egrep '[0-9]{1,3}:[0-9]{1,3}' test.txt
0
 

Author Comment

by:ibanja
ID: 17901124
That certainly does it.

I noticed a typo in my question.  I had:
grep -e '\d{1,3}:d{1,3}:' test.txt
but I'd been using:
grep -e '\d{1,3}:\d{1,3}:' test.txt    

No matter.  It didn't work.

Thanks amit_g
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question