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 5 years ago.
Improve this question
I had requirement to validate 5 digit String with - at third position.
For example i want to validate number like these 12-18 ,20-35,40-45.I need java string for the same
you can use the regex
^\d{2}-\d{2}$
to match , see the regex101 demo
Related
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 2 years ago.
Improve this question
Why it's showing error, when I enter just 5 digit number in long data type?
Numbers starting with 0 are interpreted as octal numbers in Java, that are 8-based numbers. A 9 or 8 cannot appear in octal number, thus the warning.
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 2 years ago.
Improve this question
Write a Java program that keeps a number from the user and generates an integer between 1
and 7 and displays the name of the weekday.
Create a Strint array with all weekdays ({"Sunday", "Monday"...}) and than get the name by index like this:
int day = 2;
System.out.println(weekdays[day - 1]);//output Monday
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
What I have:
String result = "<>hello<!><>Soumik<!><>Having a wonderful day?<!>";
What I need:
resultStrings = ["hello", "Soumik", "Having a wonderful day?"];
This regex should do the trick:
<[^>]*>([^<]+)<
Find all matches, and extract capturing group 1 from each.
Regex demo
How about that:
result = result.replace("<", "");
result = result.replace(">","";
resultStrings = result.split("!");
It's really simple.
I don't know other conditions so it may not be useful. Please add conditions so I can respond to it.
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 7 years ago.
Improve this question
The user input will only be accepted when,
Only upper case letters 'X','O','D','L','E' are present in the user input.
Any amount of 'O's only when in between 'D's
'DLE' is at the end and not by itself.
'X' counts as anything.
So for example the user input: 'DDLE', 'DOODLE', 'XXXDODOOOODLEDLX' - will work.
But these examples will not work ("error, wrong input"): 'DLE','DOOODLLE' 'DLEDOD'
based on criteria and examples provided
^(?=.+[DX][LX][EX]$)(?!.*[^DO]O+[^DO])[XODLE]+$
^(?=.+[DX][LX][EX]$)(?!.*[^DO]O+)(?!.*O+[^DO])[XODLE]+$
Demo
or depends on your interpretation of "'X' counts as anything" - meaning DOODDLEX is valid
^(?=.+[DX][LX][EX]X*$)(?!.*[^DO]O+[^DO])[XODLE]+$
^(?=.+[DX][LX][EX]X*$)(?!.*[^DO]O+)(?!.*O+[^DO])[XODLE]+$
or as suggested below
^(?=.+[DX][LX][EX]X*$)(?!.*[^DOX]O+)(?!.*O+[^DOX])[XODLE]+$
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
I am trying to print this integer 12345679 like 1,234,68. I was trying to do like this.
System.out.println(count+" "+"$"+fm.format(NumberFormat.getNumberInstance(Locale.US).format(avg)));
How can I do this in java??
NumberFormat currencyInstance = NumberFormat.getCurrencyInstance(Locale.US);
currencyInstance.setMaximumFractionDigits(0);
System.out.println(currencyInstance.format(12345679));
Output: $12,345,679