How to count Upper-Case, Lower-Case and special characters [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I want to create a GUI in C#. In this GUI, I have a single text field and when I fill this text field, I would like to see how many Upped-case, Lower-case and special characters are used.

About upper and lower take a look this.
int upperCasecount = s.Count(c => char.IsUpper(c));
int lowerCaseCount = s.Count(c => char.IsLower(c));
This is for the case of special characters count.
int numOfSpecialChar = s.Count(c => !char.IsLetterOrDigit(c));

Related

String Manipulation using regex and rules [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I'm new to regex but it looks as though this will work for what I need, but I just can't get my head around it.
I have a string "MAMMOTH 9MM" as an example.
All should stay upper case except the specified chars of "MM" after any digit.
Should be simple?
You can look for regular expression patterns and apply a lambda function to modify the matches:
input = Regex.Replace(input, #"(?<=\b[0-9]+)MM\b", m => m.ToLower())

Extract number between bracket and colon [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I need a regular expression to extract number 513922 from this string.
Error detected (513922: settings can not be applied.), param d1=0.0, d2=0.0 in operation mode
If you insist on regular expression:
string source =
"Error detected (513922: settings can not be applied.), param d1=0.0, d2=0.0 in...";
// 513922
string result = Regex.Match(source, #"(?<=\()[0-9]+(?=:)").Value;
// if you want integer representation:
int number = int.Parse(result);

RegExp to search words starts with numbers and special characters only using C# [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to perform a search to C# list object to find all products starts with any number or special characters only. I am looking for a Regular expressions for this scenario.
Please help
Assuming you list is a list of string:
var newList = yourList.Where(element => Regex.IsMatch(element, #"^[^a-z]", RegexOption.IgnoreCase);
It will give you a sublist of all the elements that doesn't start with a letter in the range a-z.

Trim empty spaces in int array [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I need to trim the trailing spaces at the start and end in this int array and how can I do it, also I am not getting Trim() function anywhere here. Pls suggest me.
int[] arrPCT = dtOld.AsEnumerable().Select(r => r.Field<int>("PCT")).ToArray();
int are numeric values. They don't contain spaces (or any other char). It makes no sense trying to trim them.
int[] arrPCT = dtOld.AsEnumerable().Select(r => r.Field<int>("PCT").Trim()).ToArray();
If r.Field("PCT") value is of string type.

Create a 6 digit sequence number in c# [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How do i create a six digit sequence number in c# ?
Is there any other way than storing a string in the database like "000000" and later on incrementing it through the last inserted value ?
Use a plain old number as a sequence, this is what your DB will provide. If you want to display it with six digits, just call: yourNumber.ToString("D6")
(see docs)

Categories

Resources