Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


Closed Thread
  Search this Thread
Old 02-15-2005, 02:24 PM   #1
Registered: Feb 2005
Location: PA
Distribution: Fedora Core 3
Posts: 48

Rep: Reputation: 15
regexp help

I am no good with regular expressions. Could someone give me a regular expression that grabs (matches) sequences that include a hyphen and a number. I want to match like this:


hyphen and number and not just hyphens. I got the following:
but that matches all hyphens and numbers. I just want hyphens followed by any number of numbers. Help!

Last edited by cliff76; 02-15-2005 at 02:34 PM.
Old 02-15-2005, 02:49 PM   #2
Senior Member
Registered: Nov 2004
Location: Third rock from the Sun
Distribution: NetBSD-2, FreeBSD-5.4, OpenBSD-3.[67], RHEL[34], OSX 10.4.1
Posts: 1,197

Rep: Reputation: 47
Untested: -\d+-?
Old 03-07-2008, 09:10 AM   #3
LQ Newbie
Registered: Aug 2007
Posts: 6

Rep: Reputation: 0

Hi Dear

I don't know wat exactly u want.
Try out If u want only " - " before a number :
grep -E '[-]\d*' filename
this may help you.

Old 03-07-2008, 03:15 PM   #4
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927
Why on earth did you dig this three year old carcass of a thread up?



Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
little help for regexp EmOuBi Linux - Newbie 6 08-06-2005 03:19 AM
Regexp problem eremit Programming 6 06-23-2005 07:48 AM
regexp help ... pld Programming 1 03-15-2005 04:45 PM
regexp search for [ wijnands Linux - Newbie 3 06-22-2004 03:15 AM
Regexp stumper lackluster Programming 2 11-02-2002 01:31 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:15 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration