Mikalai Zaikin wrote:Could you try a workaround like here:
https://www.baeldung.com/spring-yaml-propertysource
Mikalai Zaikin wrote:Could you try a workaround like here:
https://www.baeldung.com/spring-yaml-propertysource
(assume your yaml is on src/main/resources)
trupti nigam wrote:The numbers will come as string like "1-2-20-21" or, 1-2-3-4" or "20-13-14-16-19"
For these I came up with:
Pattern onlyNumbers = Pattern.compile("(([1-9]|[1][0-9]|[2][0-1]\\-)++)");
But it does not work.
Carey Brown wrote:
Carey Brown wrote:"[ACFILORU](-[ACFILORU])*"
Henry Wong wrote:
trupti nigam wrote:
ignore my previous posts.
Valid: "A-C-F-O-R-U", "U-O-A", "O-R-C-A-A"
invalid: "ACFOR", "ACF-ORU","AC-OR-FU"
My previous regular expression, when using matches(), will work for this requirement.
Henry
Liutauras Vilda wrote:
trupti nigam wrote:Valid: "A-C-F-O-R-U", "U-O-A", "O-R-C-A-A"
invalid: "ACFOR", "ACF-ORU","AC-OR-FU"
Is it safe to say, that between every two characters must be a dash?
Well, not between every characters. It can't be:
A---B
Liutauras Vilda wrote:
trupti nigam wrote:Valid: "A-C-F-O-R-U", "U-O-A", "O-R-C-A-A"
invalid: "ACFOR", "ACF-ORU","AC-OR-FU"
Is it safe to say, that between every two characters must be a dash?
Carey Brown wrote:
Not sure about your use of "BUT" here.trupti nigam wrote:The patten can have any of the letters (single) separated by "-" which means "ACF-ORU" is invalid so is "ACFOR". but "A-C-F-O-R-U" is valid.
You may want to try
"[ACFILORU]+(-[ACFILORU]+)*"
Henry Wong wrote:
trupti nigam wrote:
So "AF-RU-RE" is valid pattern, so is "OUIF-AC"
Disregard my last post, as that post assumes only single characters (separated by dash) are valid. You need to clarify to specify which character combinations are valid -- and in much more detail than one example.
Henry
Henry Wong wrote:
trupti nigam wrote:Hope this clarifies.
Actually no. Regular expressions are very particular. You need detail examples that matches. You also need detail examples that don't match. Otherwise, you won't get to cover all the edge conditions.... However, I am in a good mood, so I can give it a shot...
trupti nigam wrote:I need to match any letters "A", "C", "F", "I", "L", "O", "R", "U" and a "-" in between. "-" can not be in the beginning and at the end letters through.
To match a single case of one of those letters, the pattern is ... "[ACFILORU]".
To match two cases of one of those letters, separated by a dash, the pattern is ... "[ACFILORU]-[ACFILORU]".
To make the second case optional, so that it can match either one or two letters, the pattern is ... "[ACFILORU](-[ACFILORU])?".
And finally, to make two or more optional cases, so that it can match either one or more letters, the pattern is ... "[ACFILORU](-[ACFILORU])*".
I will let you figure out the other pattern yourself.
Hope this helps,
Henry
Jeanne Boyarsky wrote:[ACFILORU*-] Matches only one character which isn't what you want.
[ACFILORU-]* Matches zero or more of these characters.
But you have rules for the first and last characters too. Can you fill in the blanks:
trupti nigam wrote:I need to match any letters "A", "C", "F", "I", "L", "O", "R", "U" and a "-" in between. "-" can not be in the beginning and at the end letters through.
The other pattern to match is any nos between 1-21 and separted by "-". Again "-" can not be in the beginning and at the end letters through.
Hope this clarifies.
Thanks you!