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]+$
Related
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
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
For example, if I have a string (24/25), how would I go about being left with two double values of 24 and 25. My objective to to eventually, given a set of number of that form, divide each of them, and add to get the average. I'm fairly new to Java and I honestly am so confused as where to even begin. Thank you!
As Andreas said. First you need to take the substring between brackets. Use String.substr
Now split 24/25 to 24 and 25. You can use String.split
Then you can parse them with Double.parse
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 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
it is possible to assign that big number in java? i need to make a calculation of 39 digits value. could any help? Thanks
Problem:
Consider the following composite number:
340282367237851113557325445936183246849
Write a Java method to find two numbers whose product is the above number.
I guess you need to check out the BigInteger of the java API. That might be able to store your results of those much big numbers. Read the documentation,
http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html
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 don't know a single bit about regex. I want to find certain occurences in my java project using eclipse. The words could be
SEQ_NUM
SEQNUM
SEQNUMBER
SEQ_NUMBER
searching strings based on word "seq" would generate lots of results. What regex should suffice my problem?
These four cases can be combined to the following regex:
SEQ_?NUM(BER)?
SEQ_?NUM(BER)?
SEQ - must exist
_? - '_' can appear 0 or 1 time
NUM - NUM must also exist
(BER)? - 'BER' can appear 0 or 1 time
This should work for you.
SEQ[_NUMBER]+