Uppercase word in PERL


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Uppercase word in PERL
# 1  
Old 12-07-2009
Java Uppercase word in PERL

how do i print uppercase words in a string in PERL
For example
$str=" welcome to UNIX programming"
should print UNIX

$str="WELCOME to unix programming"
should print WELCOME

i itried the following
/[.!?"]\s+[A-Z]\w+\b/ $str

Can u help me in to get a uppercase word in PERL
# 2  
Old 12-07-2009
Hint:

Code:
#!/usr/bin/perl
use strict;
use warnings;

my $str1 = "welcome to UNIX programming";
my $str2 = "WELCOME to unix programming";

$str1 =~ /([A-Z]+)/;
print "$1\n";
$str2 =~ /([A-Z]+)/;
print "$1\n";

# 3  
Old 12-07-2009
Thanks fot the solution...
if the string is
D fm_mtx_cust_check_IMSI - PCM_OP_SEARCH output Function:
the above code is returning only PCM and not PCM_OP_SEARCH.
Any clue?
# 4  
Old 12-07-2009
The character sequence [A-Z] encloses all valid characters. If you need more than just A-Z, add them to it.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl lwp find word and print next word :)

hi all, I'm new there, I'm just playing with perl and lwp and I just successfully created a script for log in to a web site with post. I have a response but I would like to have something like this: I have in my response lines like: <div class="sender">mimi020</div> <some html code.....>... (3 Replies)
Discussion started by: vogueestylee
3 Replies

2. Shell Programming and Scripting

MS Word + Perl

The below snippet will find and replace string in a word document (.doc)..but the string which is replaced is highlighted how to remove the highlighted part..for eg the string what i want to replace is "Apple" and it is highlighted in yellow color when i replace it with "Grapes" the same color is... (1 Reply)
Discussion started by: rajkrishna89
1 Replies

3. Shell Programming and Scripting

SED (or other) upper to lowercase, with first letter of first word in each sentence uppercase

The title pretty much defines the problem. I have text files that are all in caps. I would like to convert them to lowercase, but have the first letter of the first word in each sentence in uppercase. I already have SED on the server for fixing / tweaking text files, but I'm open to other... (5 Replies)
Discussion started by: dockline
5 Replies

4. Shell Programming and Scripting

Validating uppercase/lowercase of user input with perl compared to unix folders

Hi, I need to copy files from a source directory to a destination directory in unix. I'm using the file::copy for the actual copy. The problem is that the source and dest directories are supplied by different users, who might type the name of the directories in various combinations of lower... (6 Replies)
Discussion started by: Furou
6 Replies

5. Shell Programming and Scripting

making the first character of word using uppercase using awk and sed

I want to make the first character of some words to be uppercase. I have a file like the one below. uid,givenname,sn,cn,mail,telephonenumber mattj,matt,johnson,matt johnson,mattj@gmail.com markv,mark,vennet,matt s vennet,markv@gmail.com mikea,mike,austi,mike austin,mike@gmail.com I want... (3 Replies)
Discussion started by: matt12
3 Replies

6. Shell Programming and Scripting

extract whole thing in word, leaving behind last word. - perl

Hi, i've a string /u/user/DTE/T_LOGS/20110622_011532_TEST_11_HD_120/HD/TESi T_11_HD_120/hd-12 i need to get string, like /u/user/DTE/T_LOGS/20110622_011532_TEST_11_HD_120/HD the words from HD should get deleted, i need only a string till HD, i dont want to use any built in... (4 Replies)
Discussion started by: asak
4 Replies

7. Shell Programming and Scripting

perl (word by word check if a hash key)

Hi, Now i work in a code that 1-get data stored in the database in the form of hash table with a key field which is the " Name" 2-in the same time i open a txt file and loop through it word by word 3- which i have a problem in is that : I need to loop word by word and check if it is a... (0 Replies)
Discussion started by: eng_shimaa
0 Replies

8. UNIX for Dummies Questions & Answers

using grep and to remove all word with uppercase

I try to write a small script that looks in the file tt for all the words that start with m in lowercase and in which there is no uppercase. #!/bin/sh grep ^m\.*\.\.* tt (4 Replies)
Discussion started by: cfg
4 Replies

9. Shell Programming and Scripting

How to find a particular word in perl

Hi I need the out put for how many times a particular word in a line . How to do it in a perl programme. Please reply ASAP... Regards Harikrishna (2 Replies)
Discussion started by: Harikrishna
2 Replies
Login or Register to Ask a Question