Computer Science, asked by rohithspacejet, 4 months ago

suggest appropriate functions for the following tasks:
i.To check whether the string contains digits
ii.To find for the occurance a string within another string
iii.To convert the first letter of a string to upper case
iv.To capitalize all the letters of the string
v. to check whether all letters of the string are in capital letters
vi. to remove from right of a string all string combinations from a given set of letters

Answers

Answered by prashualdogra
2

Answer:

1.Using Regular Expression:

Get the String.

Create a Regular Expression to check string contains only digits as mentioned below: regex = "[0-9]+";

Match the given string with Regular Expression. ...

Return true if the string matches with the given regular expression, else return false.

2.You are given a string and a word your task is that count the number of the occurrence of the given word in the string and print the number of occurrence of the word.

3.Using Java Inbuilt methods

Iterate the string, if any space if found in the previous iteration and the current element is not space then call the toUpperCase() method to put the first letter of the word in uppercase format and append the string in the buffer.

4.upper() and . lower() string methods are self-explanatory. Performing the . upper() method on a string converts all of the characters to uppercase, whereas the lower() method converts all of the characters to lowercase.

5.The isupper() methods returns “True” if all characters in the string are uppercase, Otherwise, It returns “False”. Syntax : string

6.Given a string, eliminate all “b” and “ac” in the string, you have to replace them in-place, and you are only allowed to iterate over the string once.

Similar questions