LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 01-10-2011, 02:22 PM   #1
Garrett85
Member
 
Registered: Jan 2011
Posts: 240

Rep: Reputation: 5
grep reg exp


My assingment:

Write a regular expression that would match lines of the following form:

City, ST 12345

City can be more than one word, and ST is always any two capital letters.

HINT: Since the city name can be almost anything but is always followed by a comma so it might be a good idea to start matching at the comma

This is what I have
grep "*[A]*[a-z],[A-Z]{2}[1-9]{5]"

My instructors feedback:
Excellent start however make sure you encompass your regex in one set of quotes to allow you to include spaces. Also, using {} will cause an error. You must either escape the brackets or use a perl flag.

I've added the quotes but how do I write a perl flag and or, escape the {} brackets. Thanks.
 
Old 01-10-2011, 02:28 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.


http://www.linuxquestions.org/questi.../regex-853637/

Last edited by Tinkster; 01-10-2011 at 02:31 PM.
 
  


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
grep reg exp Garrett85 Linux - Newbie 2 01-15-2011 05:13 PM
Need help with grep syntax and reg exp Rush_898 Linux - General 2 01-08-2008 11:28 AM
GREP - reg exp to find words ending with .V and .TO vikram_cvk Linux - Server 5 12-22-2006 02:47 PM
python reg exp help Bopi Programming 1 12-03-2006 03:29 AM
Reg Exp ugenn Programming 4 09-19-2002 01:01 PM


All times are GMT -5. The time now is 09:00 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration