LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Pattern Matching (https://www.linuxquestions.org/questions/linux-newbie-8/pattern-matching-879930/)

kdate 05-10-2011 07:15 PM

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.

frankbell 05-10-2011 08:15 PM

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

http://www.regular-expressions.info/tutorial.html

grail 05-10-2011 10:08 PM

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.

astromime 05-15-2011 01:27 PM

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?

kdate 05-23-2011 05:27 PM

Thanks for that everyone,

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


All times are GMT -5. The time now is 09:31 AM.