LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Closed Thread
  Search this Thread
Old 02-15-2005, 01:24 PM   #1
cliff76
Member
 
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:

text-23-more-text-456

hyphen and number and not just hyphens. I got the following:
-[\d]*
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 01:34 PM.
 
Old 02-15-2005, 01:49 PM   #2
sigsegv
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, 08:10 AM   #3
surya_b4u
LQ Newbie
 
Registered: Aug 2007
Posts: 6

Rep: Reputation: 0
Wink

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.

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

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

Closed.


Cheers,
Tink
 
  


Closed Thread



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 02:19 AM
Regexp problem eremit Programming 6 06-23-2005 06:48 AM
regexp help ... pld Programming 1 03-15-2005 03:45 PM
regexp search for [ wijnands Linux - Newbie 3 06-22-2004 02:15 AM
Regexp stumper lackluster Programming 2 11-02-2002 12:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:26 AM.

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