Regular expression, to get text after blank space [closed] - java

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 9 years ago.
Improve this question
I have this text:
1 A Maths
And i would like to get only Maths.
I donĀ“t know about regular expressions.
Can any one help me, please?
Thanks

Why don't you split the string ?
String chain="A Maths";
String[] array=chain.split(" ");
String number=array[0];
String course=array[1];
...
How to split a string in Java

Related

last two occurance of semicolon(;) in given String using Java [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 1 year ago.
Improve this question
How do I get the after last two semicolon's occurrences of a string ?
Example:
Mobiles;Students;Test;Yes;1234
The output should be
Yes;1234
Using a regex replacement, we can try:
String input = "Mobiles;Students;Test;Yes;1234";
String output = input.replaceAll("^.*;([^;]+;[^;]+)$", "$1");
System.out.println(output); // Yes;1234

Mask String before occurrence of first whitespace [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 mask the string before the first white space
Eg. "123 test1" mask to xxtest1
"12/6786 test2" mask to xxtest2
Using string replace all with regex
I tried this ^.*?[^\s]*\s and it seems to be working to your case.

how i can make my variable equal any element of my 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 have
String[] country={"USA","ks a","UK","France"};
I have a variable String z.
I want to say
if(z.equals(any element of my array (USA or ks or France)
but randomly:
if(z.equals(country[i]){
Doing action any code
}
Can anybody help me?
you can use
if ( Arrays.asList(country).contains(z)) {
// your code
}

Regex for a pattern [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 want to write a regex for this below pattern.
of John at /roger/adam/sam
here John is a value(can be alphanumeric) and /roger/adam/sam is an XPath with can change.
I want to replace all such instances with
of $value at $XPath
You can use the following to match
(of\s*)[a-zA-Z\d:-]+(\s*at\s*).*?(?=\s)
and replace with $1$value$2$XPath
See DEMO

Changing the Lengths of Words in a String - Java [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 am currently writing a game in Java, where words in a string will have to be all changed to equal 5 characters a word.
eg. I am writing in Java
Iamwr iting inJav a
I wonder if anyone knows how I would do this?
First remove spaces between words.
Then split that resulting String to length with 5.
Add a space after every 5 character.

Categories

Resources