Hey all, I have been trying to come up with a regular expression that can detect a name in a flat-file database. The flatfile has some info. lets say for example i got a flat-file for a Dentist office and i want to add a new patient to this file if he is not present. simple enough right!
But wait, i got patients that share parts of a name.

Example:
Don Phillie Johnson
Alexander simon
simon DeGauo
simon DeGauo Henderson
Alex Johnson
Alex Johnson Stevens

You see i need to come up with somewhat of a smarter regex that can go do this. Now one thing that i forgot to mention in the scenerio is that the flat-file has different doctors.
so if you had something like the following it is ok:
123!simon DeGauo!rm-200!Dr. Andre
123!simon DeGauo!rm-200!Dr. Banks
Now you see i am gonna have to do a regex that looks at both the patient name (variation sensative) and the doctor.
I know the explanation is not the best but i think you guys can look at the follwing and get a clue also.

$patient = "Alex"; $new_doc = "Kessler"; open (REC, "record.data"); @data = <REC>; close (REC); foreach $line (@data) { my ($id, $patient, $room, $doc) = split (/!/, $line); if (($patient =~ /($new_patient)/i) && ($doc =~ $new_doc)) { print "$line\n"; } else { print "NO PATIENT BY THAT NAME\n"; }

In reply to regular expression issue by data67

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.