473,382 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Counting numbers, letters and other symbols in string.

Hello, I have a variable string, named "line", a person writes some random stuff in it, and I need to count how many letters are in his text, how many numbers, and then how many other symbols. I have no idea how to do it. Hope you can help.

This is what I have right now:

string line= "";
Console.Write("Write your line: ");
line= Console.ReadLine();

What shoud I add next?
Thanks in advance.
Nov 16 '11 #1

✓ answered by GaryTexmo

Check out the Char structure... there are many methods there such as IsLetter, IsDigit, and IsSymbol that you can use. Use those to test each character in the string and increment a counter :)

2 2570
GaryTexmo
1,501 Expert 1GB
Check out the Char structure... there are many methods there such as IsLetter, IsDigit, and IsSymbol that you can use. Use those to test each character in the string and increment a counter :)
Nov 16 '11 #2
Thanks, these functions were excatly what I needed
Nov 19 '11 #3

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

Similar topics

2
by: Jeff | last post by:
Hi, I am trying to insert a space before all capital letters in a string except the first occurrence. For example: FirstSecondThird would become First Second Third Is there a regular...
2
by: Dave | last post by:
Can someone tell me how to add Greek letters to a string? In this case I need to add the Greek letter mu to a string for display on the screen and don't know how to do it. Thanks in advance for...
5
by: Alex Leach | last post by:
I need to check whether a string of letters contains any numbers at the end of the string, and if so, remove all numbers. There won't ever be numbers at the beginning or middle of the string. Any...
4
by: jerger | last post by:
i have a great program now with the help of a member from this site, but i need a little customization to meet the needs of non-english speakers... who might accidendtly type punctuation which would...
4
by: gihan99 | last post by:
hey can somebody please explane how to count letters in a string. thxs
5
by: k4m135h | last post by:
Hi, I've come across a problem where i seem to be doing the counting of numbers in a inefficient way i've got a 200x200 array with numbers ranging from 101-600 and also 0 and 1. and i need to count...
7
by: ccarter45 | last post by:
I need to count the number of letters in a string, disregarding case. It needs to use these two methods. What's wrong? import java.util.Scanner; public class CountLetters { public static void...
1
by: Alexnb | last post by:
Okay, I have a fix for this problem, but it is messy and I think there might be a better way. Heres an example: Lets say I have a string: "My name is alex" and I have another string "My name...
2
by: Edwin.Madari | last post by:
use re module import re template = '^My name is alex' astring = 'My name is alex, and I like pie' if re.match(template, astring): print 'Found it' else: print '%s does not begin with %s' %...
1
by: bambs | last post by:
how to restrict fields to numbers/ letters only? without enabling the user to passed the page until he/she writes the correct input?
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.