|
On Jan 15, 2019, at 10:01 AM, Kevin Bucknum <Kevin@xxxxxxxxxxxxxxxxxxx> wrote:
It works for me? For both version 5.2.13 and 5.5.32 (I know. We need to update) I get this:
MacDonald
McDonald
Oneill
O'Neill
From this source:
?php
/**
* Properly capitalize a name.
*
* @package NameCase
* @version 1.0.2
* @author Alex Dunae, Dialect <alex[at]dialect[dot]ca>
* @copyright Copyright (c) 2008, Alex Dunae
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @link http://dialect.ca/code/name-case/
*/
/**
* Apply properly capitalization rules to a name.
*
* @param string $str
* @returns string
*/
echo name_case('macdonald');
echo '<br>';
echo name_case('mcdonald');
echo '<br>';
echo name_case('oneill');
echo '<br>';
echo name_case("o'neill");
echo '<br>';
echo phpversion();
function name_case($str) {
// basic check for e-mail addresses to allow copy-and-paste of e-mail lists
if(strpos($str, '@') && strpos($str, '.'))
return $str;
if(function_exists('mb_convert_encoding'))
$str = @mb_convert_encoding($str, 'UTF-8', 'auto');
$processed_chunks = array();
// build name chunks
$buffer = '';
for($i = 0; $i < strlen($str); $i++) {
// check for delimiters
if(preg_match('/[\s]+/', $str[$i]) > 0 || $str[$i] == '-' ||
$str[$i] == '.' || $str[$i] == ',') {
$processed_chunks[] = _process_name_case_chunk($buffer . $str[$i]);
$buffer = '';
} else {
$buffer .= $str[$i];
}
}
$processed_chunks[] = _process_name_case_chunk($buffer);
return trim(implode('', $processed_chunks));
}
/**
* Process the chunks generated by the namecase function.
*
* This function should not be called directly.
*
* @param string $str
* @returns string
* @see name_case
*/
function _process_name_case_chunk($str) {
// Surname prefixes
if(preg_match('/^(van|von|der|la|d[aeio]|d[ao]s|dit)[\s,]*$/i', $str))
return strtolower($str);
// Ordinal suffixes (I - VIII only)
if(preg_match('/^(i{3}|i{1,2}v?|v?i{1,2})[\s,]*$/i', $str))
return strtoupper($str);
if(function_exists('mb_convert_case'))
$str = mb_convert_case($str, MB_CASE_TITLE, 'UTF-8');
else
$str = ucfirst(strtolower($str));
// Second letter capitalized, like D'Angelo, McDonald, St. John, 0'Neil
if(preg_match('/(^|\s)+(Mc|[DO]\'|St\.|St[\.]?[\s]|Dewolf)/i', $str)) {
$str[2] = strtoupper($str[2]);
return $str;
}
// Third letter capitalized, like MacDonald, MacRae
if(preg_match('/(^|\s*)(Mac)(allist|arth|b|c(allu|art|ask|l|r|ull)|d|f|g|i(nn|nty|saa|v)|kinn|kn|l(a|ea|eo)|m|na[mu]|n[ei]|ph|q|ra|sw|ta|w)/i', $str)) {
// not h,
$str[3] = strtoupper($str[3]);
return $str;
}
return $str;
}
-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxxxxxxxx] On Behalf Of Jon Paris
Sent: Monday, January 14, 2019 6:56 PM
To: Midrange Systems Technical Discussion
Subject: Re: Need help to convert a name in upper case, to mixed case
Will do mate.
Jon Paris
www.partner400.com
www.SystemiDeveloper.com
On Jan 14, 2019, at 7:54 PM, Bruce Vining <bruce.vining@xxxxxxxxx> wrote:
Jon,
Let me know if I can help. It would certainly make a very useful
function :)
On Mon, Jan 14, 2019 at 6:47 PM Jon Paris <jon.paris@xxxxxxxxxxxxxx> wrote:
Good point Bruce - Foolishly I had tested it with ONEIL and not O'NEIL.
Doh!
Can't get the PHP to work though - there's an error but I can't
figure it out.
Jon Paris
www.partner400.com
www.SystemiDeveloper.com
On Jan 14, 2019, at 5:45 PM, Bruce Vining <bruce.vining@xxxxxxxxx>wrote:
wrote:
Jon,
It appears to correctly handle O'NEIL vs ONEIL. And it also appears
to handle prefixes pretty well -- as in CARMEN DE LAVALLADE being
returned as Carmen de Lavallade.
On Mon, Jan 14, 2019 at 3:58 PM Jon Paris <jon.paris@xxxxxxxxxxxxxx>
that
This site https://dialect.ca/code/name-case/#output <
https://dialect.ca/code/name-case/#output> has a Regex based
routine
jwoehr@xxxxxxxxxxxxxxxxxxxxxxxx>looks as if it could be converted to Regex in RPG or set up a
simple in-house web service or whatever to use it. PHP Source code
is here https://dialect.ca/code/name-case/name_case.phps <
https://dialect.ca/code/name-case/name_case.phps> but could be
adapted quite easily. It seems to handle most of the MACDONALD,
MCDONALD type stuff but not ONEIL.
Jon Paris
www.partner400.com
www.SystemiDeveloper.com
On Jan 14, 2019, at 4:54 PM, Jack Woehr <
receivedwrote:
jwoehr@xxxxxxxxxxxxxxxxxxxxxxxx>
On Mon, Jan 14, 2019 at 2:46 PM Jack Woehr <
wrote:computing
There's no algorithm other than dictionary lookup that's going to
distinguish between the separate cases of
MacDonald
versus
Mackenzie
Besides, some people write O'Neil and some Oneil. What can a poor
device do? :)
--
Jack Woehr
Absolute Performance, Inc.
12303 Airport Way, Suite 100
Broomfield, CO 80021
NON-DISCLOSURE NOTICE: This communication including any and all
attachments is for the intended recipient(s) only and may contain
confidential and privileged information. If you are not the
intended recipient of this communication, any disclosure, copying
further distribution or use of this communication is prohibited.
If you
delete/destroythis communication in error, please contact the sender and
listall copies of this communication immediately.list
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailing
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx Toquestions.
subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related
link: https://amazon.midrange.com
Help support midrange.com by shopping at amazon.com with our
affiliate
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailing
listTo post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To
subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our
affiliate
link: https://amazon.midrange.com
--
Thanks and Regards,
Bruce
931-505-1915
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailing
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To subscribe,questions.
unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related
link: https://amazon.midrange.com
Help support midrange.com by shopping at amazon.com with our
affiliate
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our
affiliate
link: https://amazon.midrange.com
--
Thanks and Regards,
Bruce
931-505-1915
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To
subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link: https://amazon.midrange.com
[https://www.medtronsoftware.com/img/MedtronMinilogo.bmp] Kevin Bucknum
Senior Programmer Analyst
MEDDATA / MEDTRON
120 Innwood Drive
Covington LA 70433
Local: 985-893-2550
Toll Free: 877-893-2550
https://www.medtronsoftware.com
CONFIDENTIALITY NOTICE
This document and any accompanying this email transmission contain confidential information, belonging to the sender that is legally privileged. This information is intended only for the use of the individual or entity named above. The authorized recipient of this information is prohibited from disclosing this information to any other party and is required to destroy the information after its stated need has been fulfilled. If you are not the intended recipient, or the employee of agent responsible to deliver it to the intended recipient, you are hereby notified that any disclosure, copying, distribution or action taken in reliance on the contents of these documents is STRICTLY PROHIBITED. If you have received this email in error, please notify the sender immediately to arrange for return or destruction of these documents.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link: https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.