hi everyone.
i need to check whether the string contains any uppercase characters.
i dont want to convert them to upper case. just need to count the upper case variables.
Thanks
yah like this in if condition
Char.IsUpper(string yourstring, int index)
where index is the possition where you want to check whether it has upper case character or not
Cheers @soorya_prasad
@AshwinS2 Hi, this condition gives true only if all the characters in the string is uppercase.
i need if any one character is upper case it should give true value.
You can use palaniappan query or
Use string var.touppervariant(index position).contains(“A”)
Thanks
Ashwin.S
@Palaniyappan I need to check the whole string at once. I dont want to check the particular index. if my string contains any uppercase character it should return true value.
@soorya_prasad as mentioned by @Palaniyappan and @AshwinS2 add one more step for your string . Create a character Array of your string then apply this in for each loop Char.IsUpper(CharacterArray[i]) and increment the counter then you will get the count, if count greater than 0 then yes else No.
Use below code to check Upper case in String it will return number how many upper case character …if it return 0 then no upper case in the string
system.Text.RegularExpressions.Regex.Matches(yourInputString,“[A-Z]”).Count.ToString
@soorya_prasad you can use as shown below
assign v1 = “uIpAth”
assign v1 = System.Text.RegularExpressions.Regex.IsMatch(v1,“[A-Z]”)
Now this will give boolean result that is true
Fine
we can use REGEX
out_count = System.Text.RegularExpressions.Regex.Matches(yourInputString,“[A-Z]”).Count.ToString
to know which characters
then simiply
out_matches = System.Text.RegularExpressions.Regex.Matches(yourInputString,“[A-Z]”)
Where out_matches is a ienumerable of string type
–now use a for each loop and pass the above variable
–inside the loop use write line and mention as item.tostring which will show us the character in caps
Cheers @soorya_prasad
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.