View source code
Display the source code in std/string.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Function std.string.soundexer
Soundex algorithm.
char[4] soundexer(Range)
(
Range str
)
if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && !isConvertibleToString!Range);
char[4] soundexer(Range)
(
auto ref Range str
)
if (isConvertibleToString!Range);
The Soundex algorithm converts a word into 4 characters based on how the word sounds phonetically. The idea is that two spellings that sound alike will have the same Soundex value, which means that Soundex can be used for fuzzy matching of names.
Parameters
Name | Description |
---|---|
str | String or InputRange to convert to Soundex representation. |
Returns
The four character array with the Soundex result in it. The array has zero's in it if there is no Soundex representation for the string.
See Also
Note
Only works well with English names.
Example
writeln(soundexer("Gauss")); // "G200"
writeln(soundexer("Ghosh")); // "G200"
writeln(soundexer("Robert")); // "R163"
writeln(soundexer("Rupert")); // "R163"
writeln(soundexer("0123^&^^**&^")); // ['\0', '\0', '\0', '\0']
Authors
Walter Bright, Andrei Alexandrescu, Jonathan M Davis, and David L. 'SpottedTiger' Davis
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.