|
Extract First Letter of Each Word to Form an Acronym
By: Bruce Bahlmann - Contributing Author (your
feedback
is important to us!)
In rails development, you may run across a case where you are given a string
of characters (for example a job title, a phrase, or some other group of
words) and want to simply extract the first letter of each word to form an
acronym or some other cryptic word to use as a password.
Rails provides a fairly easy way to do this via chaining several functions
together as shown below:
[Extract first letter of each word in a string]
s = "this is my best try"
s.split(/\s+/).map(&:first).join
=> timbt
## Or to make these all CAPS simply add upcase
s.split(/\s+/).map(&:first).join.upcase
=> TIMBT
Note: One of the time tested best ways to select passwords is to
obtain an old book of ancient proverbs or sayings and then extract the
letters from these proverbs or sayings to form your password. The older the
book the better. To further increase security, you can come up with your own
substitution system (numbers for certain letters) and/or which letter from
each word according the word's position within the phrase. The result is
often a catchy yet an extremely safe password. I've used this practice in
the past to generate SNMP community strings and root passwords.
Can Birds-Eye.Net help you or your Company?
Receive your Birds-Eye.Net articles and white
papers hot off
the presses by adding our RSS feed to your reader.
|
|
|
(C) Copyright Birds-Eye.Net, All rights reserved.
It is against the law to reproduce this content or any portion of it in any form without the explicit written permission of Birds-Eye Network Services, LLC. Federal copyright law (17 USC 504) makes it illegal, punishable with fines up to $100,000 per violation plus attorney's fees.
|