473,473 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

I want to check that all characters in a word are capital or not

7 New Member
This code I have written but even Good not contains all capital words like GOOD the output of my code is All word is capital which is wrong.

Can any one help me to solve this problem.

Expand|Select|Wrap|Line Numbers
  1. my $element = "Good";
  2. if ($element =~ /[A-Z]/g)
  3. {
  4.  print "All word is capital";
  5. }
  6. else
  7. {
  8. print "Not all word capital"
  9. }
Mar 6 '08 #1
1 1878
nithinpes
410 Recognized Expert Contributor
Do a complete string match. ^ stands for begining of string and $ for end of string. using /g won't server the purpose. This will tell interpreter to not stop with first search and continue further, but will not return false if pattern is not found after the first match.

Expand|Select|Wrap|Line Numbers
  1. if ($element =~ /^[A-Z]+$/)
  2. {
  3.  print "Whole word is capital";
  4. }
  5. else
  6. {
  7. print "Whole word is not capital"
  8. }
  9.  
Mar 6 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Andy Jacobs | last post by:
Hi All I've written a little CMS with a WYSIWYG editor from www.interactivetools.com. Everything works ok until they try and copy text from MS Word. When they do this, apostrophes change to a...
14
by: deko | last post by:
Is there a way to check user input for illegal characters? For example, a user enters something into a text box and clicks OK. At that point I'd like to run code such as this: illegal =...
2
by: CR | last post by:
having a problem with the final strcpy of filename from *argv into a structure containing an array with 20 elements called fname It seems that strcpy & strncpy aren't stopping after null is found...
1
by: j | last post by:
Hi, I've been trying to do line/character counts on documents that are being uploaded. As well as the "counting" I also have to remove certain sections from the file. So, firstly I was working...
7
by: AA Arens | last post by:
I want to fill in data in the fields and the first caracter is now automatic capitalized, however, I do not want this as abbiviations must be fully in capitals. How to get it? Bart Acc 2003.
4
by: hanseymoon | last post by:
Dear newsgroup: I've got this long function, which works good overall to spell check words from a dictionary and I am not in a position to replace it. Can someone please see where or how it...
5
by: Moham12345 | last post by:
How can i detect if there is more then capital letter in a word?
0
by: wbosw | last post by:
I'm trying to create a regex to find more than one capital letter position within a word. The below regex, finds the first capital letter in the word and returns the index for that character. I...
4
by: zcabeli | last post by:
Hi all, i'm currently struggling to perform the above mentioned replacement. i already know how to catch the first letter in each word and determined if it's regular or capital. however, i...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.