Extract First letter from each word
Hi All,
I have a requirement to extract first letter of each word as shown in below example
input: abcd output: a
input: abcd efgh output: ae
input: abcd efgh ijkl output: aejany help will be highly appreciated
I am on db version 11g
jeneesh wrote:
Just a note - This will not take care of spaces at the end of the line..You're right, and not just spaces but any non-word characters. Here is fixed solution:
with t as (
select 'abcd ' str from dual union all
select 'abcd efgh.' from dual union all
select 'abcd efgh ijkl,' from dual union all
select ' a abcd efgh ijkl! ' from dual
select str,
'[' || regexp_replace(str,'\W*(\w)(\w*)|(\W*$)','\1') || ']' initials
from t
STR INITIALS
abcd [a]
abcd efgh. [ae]
abcd efgh ijkl, [aei]
a abcd efgh ijkl! [aaei]
SQL> BTW, oldie_63's solution takes care of spaces but not:
with t as (
select ' abcd' str from dual union all
select '.abcd efgh' from dual union all
select ',abcd efgh ijkl' from dual union all
select '! a abcd efgh ijkl' from dual
select str,
'[' || trim(regexp_replace(str,'(\S)\S*\s*','\1')) || ']' initials
from t
STR INITIALS
abcd [a]
.abcd efgh [.e]
,abcd efgh ijkl [,ei]
! a abcd efgh ijkl [!aaei]
SQL> Also, OP needs to clarify what to do with hyphenated words:
SQL> with t as (
2 select 'sugar-free' str from dual
3 )
4 select str,
5 '[' || regexp_replace(str,'\W*(\w)(\w*)|(\W*$)','\1') || ']' initials
6 from t
7 /
STR INITIALS
sugar-free [sf]
SQL> with t as (
2 select 'sugar-free' str from dual
3 )
4 select str,
5 '[' || trim(regexp_replace(str,'(\S)\S*\s*','\1')) || ']' initials
6 from t
7 /
STR INITIALS
sugar-free [s]
SQL>Or words like:
SQL> with t as (
2 select 'O''Reily' str from dual
3 )
4 select str,
5 '[' || regexp_replace(str,'\W*(\w)(\w*)|(\W*$)','\1') || ']' initials
6 from t
7 /
STR INITIALS
O'Reily [OR]
SQL> with t as (
2 select 'O''Reily' str from dual
3 )
4 select str,
5 '[' || regexp_replace(str,'\W*(\w)(\w*)|(\W*$)','\1') || ']' initials
6 from t
7 /
STR INITIALS
O'Reily [OR]
SQL> SY.
Similar Messages
-
How to capitalize the first letter of each word in a sentence?
Can anyone please explain how to split a sentence at a comma, or space or hyphen in to words and capitalize the first letter of each word. But I don't know how many words the sentence contains.
HI,
data : begin of itab occurs 0,
words(40),
end of itab.
data : v_sentence(1000).
data : lv_firstchar.
split v_sentence at ',' into table itab.
loop at itab.
translate itab-words+0(1) to upper case.
modify itab index sy-tabix.
endloop. -
Is there a command to capitalize the first letter of each word?
That is to say, can you capitalize the first letter of each word in a document like say, word? Or using the net?
Thanks guys.
(hope that makes sense.)Select the text, then Format->Change Case->Title Case (Word 2004).
-
Is there a way to auto capitalize the first letter of every word?
I Like To Type In This Way. I Was Wondering If There Is A Setting That Will Automatically Capitalize The First Letter Of Each Word So That I Don't Have To Keep Hitting Shift Before Each First Letter.
Thank YouAdamMarshall wrote:
Nice to see so many 'helpful' responses.
This casing is useful for example, on an Address field. It would be good if the OS had this option for developers.
I'm pretty sure it does as I've certainly had apps that, in certain fields, do use title case. -
Selecting one letter from a word Array (to start off a word game)
Hi,
I have been building a simple word game. It is smple but works fine. I am now trying to enhance some of the features.
I would like to see if I can display one letter of each word so the Player has a hint. Think of this as a beginners level.
The words are random from a text list. Either I can make the letters invisible and the game starts without a hint or I am able to select a letter using charAt() or creating a new variable substring()from the word which is the displayed repeatedly on the stage(not what I want)
I have not been able to find a way to display one letter and display it in the correct order within the word and keep the remaining letters invisible.
I am including the code below.
I have another question regarding looping arrays but I'll wait until I figure this out.
I hope it is not too long and I am being clear in my goals.
Thanks
import flash.net.URLLoader;
import flash.events.Event;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.events.MouseEvent;
var loader:URLLoader;
var allWords:Array;
var thisWord:String;
var textContainer:MovieClip;
var textFields:Array;
var textStyle:TextFormat;
var underline:MovieClip;
var numCorrect:uint;
var totalLetters:uint;
//variables for creating games scoring limits
var misses:uint;
var missesToLose:uint;
//buttons for new text versions
artists_mc.addEventListener(MouseEvent.CLICK, getArt);
regular_mc.addEventListener(MouseEvent.CLICK, regWords);
function intializeGame():void
loader = new URLLoader();
allWords = new Array();
textContainer = new MovieClip();
textFields = new Array();
textStyle = new TextFormat();
guesses_txt.text = "";
numCorrect = 0;
misses = 0;
missesToLose = 5;
misses_txt.text = "0";
missesToLose_txt.text = "/" + missesToLose;
textStyle.font = "Andale Mono";
textStyle.size = 48;
textStyle.bold = true;
textStyle.color = 0x5FC9D7;
textContainer.y = 125;
addChild(textContainer);
/*loader.load(new URLRequest("word_Game.txt"));
loader.addEventListener(Event.COMPLETE, reg_textLoaded);*/
guess_btn.addEventListener(MouseEvent.CLICK, guess);
//new loader events for different textGames
function regWords(event:MouseEvent):void
loader.load(new URLRequest("word_Game.txt"));
loader.addEventListener(Event.COMPLETE, reg_textLoaded);
loader.removeEventListener(Event.COMPLETE, art_textLoaded);
removeChild(textContainer);
intializeGame();
function getArt(event:MouseEvent):void
loader.load(new URLRequest("artists.txt"));
loader.removeEventListener(Event.COMPLETE, reg_textLoaded);
loader.addEventListener(Event.COMPLETE, art_textLoaded);
removeChild(textContainer);
intializeGame();
//self-explanatory
function endGame(endMessage:String):void
var winLose:MovieClip = new WinLose();
winLose.x = stage.stageWidth / 2 - 60;
winLose.y = stage.stageHeight / 2 - 70;
addChild(winLose);
winLose.end_txt.text = endMessage;
winLose.addEventListener(MouseEvent.CLICK, startOver);
function startOver(event:MouseEvent):void
event.currentTarget.parent.removeChild(event.currentTarget);
removeChild(textContainer);
intializeGame();
function reg_textLoaded(event:Event):void
var tempText:TextField;
var stringOfWords:String = event.target.data;
allWords = stringOfWords.split(",");
thisWord = allWords[Math.floor(Math.random() * allWords.length)];
totalLetters = thisWord.length;
for (var i:uint; i < thisWord.length; i++)
tempText = new TextField();
tempText.defaultTextFormat = textStyle;
tempText.name = ("textField" + i);
tempText.text = "";
tempText.selectable = false;
tempText.width = 48;
tempText.x = i * tempText.width;
textContainer.addChild(tempText);
textFields.push(tempText);
if (thisWord.charAt(i) != "")
underline = new Underline();
underline.x = tempText.x + tempText.width / 3;
underline.y = tempText.y + tempText.height / 1.8 + 5;
textContainer.addChild(underline);
textContainer.x = stage.stageWidth / 2 - textContainer.width / 2;
function art_textLoaded(event:Event):void
var tempText:TextField;
var stringOfWords:String = event.target.data;
allWords = stringOfWords.split(",");
thisWord = allWords[Math.floor(Math.random() * allWords.length)];
totalLetters = thisWord.length;
//var firstChar:String = thisWord.substring(0, 1);
for (var i:uint; i < thisWord.length; i++)
tempText = new TextField();
tempText.defaultTextFormat = textStyle;
tempText.name = ("textField" + i);
tempText.text = "";
tempText.selectable = false;
tempText.width = 48;
tempText.x = i * tempText.width;
textContainer.addChild(tempText);
textFields.push(tempText);
if (thisWord.charAt(i) != "")
underline = new Underline();
underline.x = tempText.x + tempText.width / 3;
underline.y = tempText.y + tempText.height / 1.8 + 5;
textContainer.addChild(underline);
textContainer.x = stage.stageWidth / 2 - textContainer.width / 2;
function guess(event:MouseEvent):void
if (guess_txt.text != "")
if (thisWord.indexOf(guess_txt.text) != -1)
for (var i:uint = 0; i < textFields.length; i++)
if (thisWord.charAt(i) == guess_txt.text)
textFields[i].text = thisWord.charAt(i);
numCorrect++;
if (numCorrect >= totalLetters)
endGame("You Win");
else if (guesses_txt.text == "")
guesses_txt.appendText(guess_txt.text);
misses++;
else
guesses_txt.appendText("," + guess_txt.text);
misses++;
misses_txt.text = String(misses);
if (misses >= missesToLose)
endGame("You Lose");
guess_txt.text = "";
intializeGame();Hi,
After many hours of reading and trying out different strategies, I began to think that I was trying to do to much in one section.
I created a new TextField (oneLtr) used the addChild(oneLtr) and using the charAt() method was able to isolate a uniquely different letter as a hint for each new word.
I am now trying to work out the code so the x position moves dynamicaly with each new word.
My hope was to have a leter sitting in the exact position but right now I'm learning a lot about text and arrays so that's ok.
Any suggestions and help is always great
function art_textLoaded(event:Event):void
var tempText:TextField;
var stringOfWords:String = event.target.data;
allWords = stringOfWords.split(",");
thisWord = allWords[Math.floor(Math.random() * allWords.length)];
totalLetters = thisWord.length;
//var firstChar:String = thisWord.substring(0, 1);
oneLtr.text = thisWord.charAt(2);
for (var i:uint; i < thisWord.length; i++)
tempText = new TextField();
tempText.defaultTextFormat = textStyle;
tempText.name = ("textField" + i);
tempText.text = "";
tempText.selectable = false;
tempText.width = 48;
tempText.x = i * tempText.width;
textContainer.addChild(tempText);
textFields.push(tempText);
if (thisWord.charAt(i) != "")
underline = new Underline();
underline.x = tempText.x + tempText.width / 3;
underline.y = tempText.y + tempText.height / 1.8 + 5;
textContainer.addChild(underline);
addChild(oneLtr);
textContainer.x = stage.stageWidth / 2 - textContainer.width / 2;
oneLtr.x = tempText.x - tempText.width / 3; -
How to Capitalize the First Letter in Every Word in Mysql
Hi,
I have been trying to tidy up a massive database where visitors have been sloppy when entering text. The main thing I want to do is to Capitalize The First Letter In Every Word In Mysql.
I have found the code below in PHP but it keeps finding an error on the WHILE line:
<?php ini_set('display_errors', '1'); ?>
<?php require_once('Connections/maison_connection.php'); ?>
<?php
$result = mysql_query ("SELECT column, id FROM table");
while ($row = mysql_fetch_array($result)) {
$id = $row["id"];
$column2 = ucwords($row["column"]);
$query2 = "UPDATE table SET column = '$column2′ WHERE id = '$id'";
mysql_query($query2);
?>
My table is called MailingList and the Column is called Name, so I have altered the script to this: but it still shows the same WHILE error:
<?php ini_set('display_errors', '1'); ?>
<?php require_once('Connections/maison_connection.php'); ?>
<?php
$result = mysql_query ("SELECT Name, id FROM MailingList");
while ($row = mysql_fetch_array($result)) {
$id = $row["id"];
$Name2 = ucwords($row["Name"]);
$query2 = "UPDATE MailingList SET Name = '$Name2′ WHERE id = '$id'";
mysql_query($query2);
?>
Any ideas??I got it to work this way in SQL: I am SURE there is an abbreviated way to do it, but at least it works
UPDATE MailingList SET Name = replace(Name," a"," A");
UPDATE MailingList SET Name = replace(Name," b"," B");
UPDATE MailingList SET Name = replace(Name," c"," C");
UPDATE MailingList SET Name = replace(Name," d"," D");
UPDATE MailingList SET Name = replace(Name," e"," E");
UPDATE MailingList SET Name = replace(Name," f"," F");
UPDATE MailingList SET Name = replace(Name," g"," G");
UPDATE MailingList SET Name = replace(Name," h"," H");
UPDATE MailingList SET Name = replace(Name," i"," I");
UPDATE MailingList SET Name = replace(Name," j"," J");
UPDATE MailingList SET Name = replace(Name," k"," K");
UPDATE MailingList SET Name = replace(Name," l"," L");
UPDATE MailingList SET Name = replace(Name," m"," M");
UPDATE MailingList SET Name = replace(Name," n"," N");
UPDATE MailingList SET Name = replace(Name," o"," O");
UPDATE MailingList SET Name = replace(Name," p"," P");
UPDATE MailingList SET Name = replace(Name," q"," Q");
UPDATE MailingList SET Name = replace(Name," r"," R");
UPDATE MailingList SET Name = replace(Name," s"," S");
UPDATE MailingList SET Name = replace(Name," t"," T");
UPDATE MailingList SET Name = replace(Name," u"," U");
UPDATE MailingList SET Name = replace(Name," v"," V");
UPDATE MailingList SET Name = replace(Name," w"," W");
UPDATE MailingList SET Name = replace(Name," x"," X");
UPDATE MailingList SET Name = replace(Name," y"," Y");
UPDATE MailingList SET Name = replace(Name," z"," Z"); -
Styling first letter in each line differently [was: Dreamweaver cs4 question]
I am trying to change the font in a group of text, I want to change the first letter of each sentence to a large size and different color and when I do this it changes the entire paragraph in the div, so how can I change the attribute of one letter in a word? Example: See how the first letter of each sentence spells out earth? I want to make those letters to stand out. CAN ANYONE TELL ME HOW TO DO THIS??????
Ensuring compliance with relevant environmental legislation and regulations.
Achieving and reviewing our set objectives and goals with continual improvements.
Reducing environmental pollution by reducing, recycling and re-using by-products and waste.
Training and communication to all our staff to participate and achieve environmental excellence.
Having our environmental policy documented, implemented, maintained and made available to the public and interested third parties.
Thank you in advance
[Subject line edited for clarity by moderator]Your question went unanswered for nearly a day because of the meaningless subject line you used. Please take a moment to read How to get help quickly.
There are a couple of ways to achieve what you want. The way I would do it is to make each line a separate paragraph, and wrap them in a div with an ID called "earth". The following CSS style rule will make the first letter of each paragraph 24px tall and green:
#earth p:first-letter {
color:#090;
font-size:24px;
This uses the first-letter pseudo-element and applies it to all paragraphs in the earth div. -
Hello All,
I want to get the first character of each word:
If I have "Statement To Be Parsed" so i want a query to return STBP.
Your help pleaseHi,
NB wrote:
Hello Franck,
One more thing i have the below case which is not covered
"Test STMT Func/ Brg E.O.D Act ON LINE/ Ext" i want it to be TSF/BEAOL/E
please your help againINITCAP conisders '.' to mark the end of a word, so INITCAP ('E.O.D.') returns 'E.O.D.' (all capital letters). If you want to ignore '.'s, so that you get 'Eod' (only 'E' capitalized) as a result, then use REPLACE (or some other string manipulation function) to get rid of the '.'s before calling INITCAP.
REGEXP_REPLACE (str, '[^A-Z]') returns a copy of str with all characters except those indicated inside the square brackets removed. If you want other characters (such as '/') kept, then just add them to the list inside the square brackets, like this:
SELECT REGEXP_REPLACE ( INITCAP ( REPLACE ( 'Test STMT Func/ Brg E.O.D Act ON LINE/ Ex'
, '[^A-Z/]'
) AS inits
FROM dual;Output:
INITS
TSF/BEAOL/E -
FM to translate first letter of every word to upper case.
Hi all,
I have a requirement to change the first letter of every word in sentence to Upper case.For example if the sentence is 'fifty eight thousand' it has to be changed to 'Fifty Eight Thousand'.Is there any FM to acheive this? Any help would be highly appreciated.
Thanks and Regards
Kiran.it is useful for u :
FM:ISP_CONVERT_FIRSTCHARS_TOUPPER
OR u can user below code:
translate output_string to lower case.
pos_max = strlen( output_string ) - 1.
pos = 0.
assign output_string+pos(1) to <poi>.
assign input_string+pos(1) to <hpoi>.
<poi> = <hpoi>.
assign input_string+pos(*) to <rest>.
while <rest> ca separators.
pos = pos + sy-fdpos + 1.
if pos > pos_max. exit. endif.
assign output_string+pos(1) to <poi>.
assign input_string+pos(1) to <hpoi>.
<poi> = <hpoi>.
assign input_string+pos(*) to <rest>.
endwhile. -
Making the first letter of every word a capital
hello CF oracles
could you guys please advise me the best way to make the
first letter in every word of a string a capital letter. (and make
all the other letters lower case).
eg. convert "the quick brown fox" into "The Quick Brown Fox"
or convert "THE QUICK BROWN FOX" into "The Quick Brown Fox"
I am taking form data and inserting it into my table, so i
want to get it right as the data is inserted.
i found a "UDF" on CFLIb.org that proports to do this, but i
don't know how to set up a UDF, are there other ways or is this
considered the best approach.
http://www.cflib.org/udf.cfm?id=9&enable=1
thanks for any help you can give mefound it, here's the top info, Titlecase is what you want for
this.:
changecase.cfm
Rev 1.01
cf_changecase is a simple custom tag to format case in given
string.
(c) 2001, Rizal Firmansyah, [email protected]
Input var:
* case (mandatory)
possible inputs are
- sentencecase: Sentence case (default)
- titlecase: Title Case
- lowercase: lowercase
- uppercase: UPPER CASE
"happysailingdude" <[email protected]> wrote
in message
news:e46tjv$e30$[email protected]..
> hi Dan thanks very much. I have made an executive
decision to do a bit of
> a
> hack for now as my site is only small so if a user
enters something in the
> wrong way i can quickly manually update it myself.
>
> so now i have this which works 9 times out of ten if the
user enters a one
> word name eg "bill" or "fred" of "jane" then it works
just fine
>
> the only time it doesnt work is if the user's name is
more than 1 word (or
> is
> hyphenated) eg "mary anne" or "anne-marie" hence the
first cfif line - in
> these
> cases i can manually update
>
> i put this here in case it is of use to anyone else
>
> cheers
>
> <cfif not (FORM.firstName contains " " or
FORM.firstname contains "-")>
> '#Left( UCase( "#FORM.firstName#" ), 1 )##Right( LCase(
> "#FORM.firstName#" ), Len("#FORM.firstName#" ) - 1 )#'
> <cfelse>
> '#FORM.firstName#'
> </cfif>
> -
Apple wireless keyboard misses first letter in some words
When I am typing, particularly in Word 2011, with my Apple Wireless Keyboard, it frequently does not type the first letter of a word. I have searched and can find no resolution to this problem. I have messed with Accessibility but that is all turned off. The only other bluetooth device is my mouse.
Hi,
Thanks for this. It isn't the computer though, as it will happen very quickly. For example I can type in a web address, then look up to read the web page for 20 seconds or so, then if I type again it will miss the first key stroke.
I am starting to get used to typing the first letter twice!
I can see that it is a widely reported issue with Apple Macs, but I can't find a fix for Windows. I am keen not to have to buy a new keyboard!
T23 -
First letter of each sentence in pages!
how can I fix the first letter in each sentence, it doesn't turn to uppercase automatically, although i have tryed to choose none, title case etc. in the advanced setting? what should i do?
We guess you are talking about Pages 5. You didn't say.
Feature dropped by Apple along with 100 others.
Pages '09 can capitalise the first letter of sentences automatically.
Peter -
UDF for Find the First letter from Input
Hi Masters,
I want find the first letter from input, Can any one help me on this..UDF or any solution.
Ex: E2HB means - Alpha Letter is the first
Ex: 1234 means - Number is the first
Thanks,
SivaHi Siva,
I just want to clarify this doubt, you want the first character of the string you pass to the UDF i.e if input="E2HB" output="E" and if input="1234" output="1". If my assumption is correct you can try the UDF "firstChar" I have shown below this gives exactly the output you want
public class firstLetter {
public static String firstChar(String s)
if(s==null)
return null;
if(s.equals(""))
return s;
String t="";
t+=s.charAt(0);
return t;
public static void main(String[] args) {
String s1="E2HB",s2="1234";
s1=firstChar(s1);
System.out.println(s1);
s2=firstChar(s2);
System.out.println(s2);
Regards
Anupam -
When I bought this computer it was set up for mac mail but i am not using it it's to slow. i am using my gmail thru safari and when I type an email the first letter of each sentence is NOT capitalized and it use to be, any help is appreciated.
Talk to Google. Gmail is not an Apple product. Writing an email message is using the Google editor.
-
Getting the autocomplete setting to work by typing the first letter of a word
Before I installed Firefox 5.0, I had made it so that whenever I visited a website that remembered an account/password of mine, this happened:
1.- It asked for my master password.
2.- After entering it, I would click on the form field and then type in the FIRST LETTER of the account.
3.- When entering that exact first letter, Firefox would suggest in a drop-down menu the account or accounts that started with that letter on that particular site, e.g.: say I have a Twitter account that is "koko999". If I went to twitter.com and entered the letter "k" in the form field (after entering the master password), Firefox would suggest the account "koko999" in the drop-down menu.
4.- After selecting the account that I desired from the drop-down menu, Firefox would automatically autocomplete the password.
5.- Then, if I closed Firefox, all my active accounts would close/sign out. So, if afterwards I opened Firefox, I would have to repeat from Step 1 if I wanted to use an account, e.g.: if I closed FF while having my Twitter account logged in, and then opened FF again, I would have to start from Step 1.
Now, I had this setting for a bunch of different websites. After installing Firefox 5.0, this configuration vanished or something. Now, when entering the master password, Firefox autocompletes EVERYTHING. Say, using the example from before, that I go to twitter.com. Firefox asks for the master password, I enter it and then the ID/password for the twitter account automatically fills in without me entering any letter in the form field. And I do not want Firefox to do that!
So, I'm asking for help. I know that what I what to do is not impossible, I just can't find the way to do it! I kinda need the exact steps. Thanks a lot!See:
* http://kb.mozillazine.org/Password_only_filled_after_entering_user_name
* http://kb.mozillazine.org/signon.autofillForms (false)
If you are in Private Browsing then Firefox wont fill the names and passwords automatically.
You can set the pref <b>browser.sessionstore.privacy_level</b> to 2 (never) or 1 (non-HTTPS, default in Firefox 3 versions) on the <b>about:config</b> page to disable saving cookies via session restore.
* http://kb.mozillazine.org/browser.sessionstore.privacy_level
You can also use [[Clear Recent History]] to clear the "Active Logins" when you close Firefox.
To open the <i>about:config</i> page, type <b>about:config</b> in the location (address) bar and press the "<i>Enter</i>" key, just like you type the url of a website to open a website.<br />
If you see a warning then you can confirm that you want to access that page.<br />
You can use the Filter bar at to top of the about:config page to locate a pref more easily.
Maybe you are looking for
-
JDBC Receiver doesn't work (and doesn't show any error msg)
Hi all, I'm now trying to test a file to JDBC scenario. After many msgs sent, I'm checking at sxmb_moni and the file sender is ok, the msg mapping is ok, and the JDBC receiver is ok - the status is "processed successfully". But... in my database (Ora
-
Why does my iphone send all text from only one of my contacts to my email?
Why does my iphone send all text from only one of my contacts to my email? I'm curious to know if anyone else has had this issue with the Iphone 5s...
-
[using iwl3945, it's FAST] ipw3945d fails to detect my wireless card
I have a laptop with an Intel 3945ABG wireless card and I have been using the ipw3945d daemon which has been working great. However, on a package update somewhere, it stopped working. When I try to run /etc/rc.d/ipw3945d [max@pwn ~]$ sudo /etc/rc.d
-
How to keep window always on top?
I use afloat to keep most of the window always on top but it doesn't work for some apps like excel, textwrangler etc... How can I make excel, textwrangler etc.. to stay on top even if I focus on some other apps?
-
ALTER TABLE privilege and CREATE/DROP/ENABLE/DISABLE constraint privilege
Hi, I am looking for some detailed info regarding the below previleges ALTER TABLE, CREATE CONSTRAINT, DROP CONSTRAINT, ENABLE CONSTRAINT AND DISABLE CONSTRAINT PRiVILEGES. I have two schemas 'A' and 'B', I want to provide user 'A' with Alter table,