LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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

Reply
 
Search this Thread
Old 05-10-2011, 07:15 PM   #1
kdate
LQ Newbie
 
Registered: May 2011
Posts: 2

Rep: Reputation: 0
Unhappy Pattern Matching


Hi,

I'm trying to perform a pattern matching task in a bash script. However, I'm just not getting the hang of it.

I need to check that a variable is in the format of

SURNAME, firstname or
SURNAME, Firstname

can anyone help with this?

thanks.
 
Old 05-10-2011, 08:15 PM   #2
frankbell
Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Mageia, Mint
Posts: 7,906

Rep: Reputation: 1492Reputation: 1492Reputation: 1492Reputation: 1492Reputation: 1492Reputation: 1492Reputation: 1492Reputation: 1492Reputation: 1492Reputation: 1492
This is an area of knowledge still on my to-do list, but this website might help:

http://www.regular-expressions.info/tutorial.html
 
Old 05-10-2011, 10:08 PM   #3
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,561

Rep: Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939
How are you testing for this? ie are you using bash (=~) or another command like sed? Its not that the regex will be all that different but it helps
when presenting you options. Maybe also show us what you have tried.
 
Old 05-15-2011, 01:27 PM   #4
astromime
LQ Newbie
 
Registered: May 2011
Posts: 26

Rep: Reputation: 13
is this a situation, where if the variable is not in that format, its made to be in that format?

i dont understand where youre coming from with this, but it seems a simple Perl script could help you out, i just dont understand how you would distinguish from a surname and a firstname, unless you have some form of dictionary check, or its just literally "UPPERCASENAME, l(L)owercasename" , but where are the names being read from? user input?
 
Old 05-23-2011, 05:27 PM   #5
kdate
LQ Newbie
 
Registered: May 2011
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for that everyone,

I went with parsing on ", didn't think of that one.
 
  


Reply


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
[SOLVED] Pattern matching with sed vinaytp Linux - Newbie 3 05-24-2010 07:33 AM
pattern matching vinaytp Linux - Newbie 2 10-10-2009 06:06 AM
Pattern Matching Aveltium Linux - Newbie 5 04-12-2009 11:14 PM
need help with perl - pattern matching johngreg Programming 5 10-13-2008 01:08 PM
pattern matching nadeemr Linux - Newbie 8 06-13-2007 11:05 AM


All times are GMT -5. The time now is 05:55 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration