Normally I would just construct the regex my self, but this one seems a bit complex, and if someone else has already solved it, I'd rather go with a proven solution. That said, I need a regex (or whatever) to split up a name string into its first and last halfs. Any middle name/names would be considered part of the first name, as would titles like Junior, Senior, Doctor, etc. Worse -- since some last names have spaces in them, I can't just split on the last space.
Examples of name strings that are considered legit, I italized the last names for clarity:
- Catherine Zeta-Jones
- Jean Claude Van Damme
- George W. Bush, Jr
- Madonna
- Randal L. Schwartz
- joe schmoe
Is this hopeless? Is there a module? Is there even a good formula or algorithm? Should I just split on the (num spaces/2)+1 space?
Thanks!
In reply to Name Parsing
by Adam
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|