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
Regular expression only accepts 0 or 5.
Is there a regex expression to evaluate that?
Thanks.
You can use either "0|5" or "[05]". The first is an alternative, the second is a character class. They will behave identically. See the documentation for Pattern for more information on the building blocks for regular expressions.
Read this. And use this:
"^[05]$"
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
When I use [^abc] it excludes a,b,c but I want to exclude only abc not a,b,c.
Just in principle? There are several ways to do it, depending on your context. You could use a negative lookahead, for example, which will assert what the following string must not look like.
Example text:
aba abc abx
Expression:
\b(?!abc)\w{3}\b
Matches:
aba, abx
You should update your question with context if you want specific help.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
As per Java's standard we should follow CamelCase. But why String's method substring() is not in camelCase ? Is it for any specific reason or just an mistake from the initial days ?
I'd say because substring is one physical word.
camelCase is used to separate words, substring is not to be intended as Sub String but as Substring... so the convention is respected.
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
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.
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