trupti nigam

Ranch Hand
+ Follow
since Jun 21, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by trupti nigam

Mikalai Zaikin wrote:Could you try a workaround like here:

https://www.baeldung.com/spring-yaml-propertysource



The above did not work for me. Can you check my code and see what is missing?
1 year ago

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)



Yes my yml file is in src/main/resources too.
1 year ago
Hello All,

I am not new to spring but trying to add a new module to an existing repo. This is going to be a spring module independent from the base repo.
I have Application class like below and sftpProperties configuration file. The test is unable to read this file.
Can someone please let me know what am I missing.



When I run the test the port value is null which seems that spring is unable to read the application.yml file.

the application.yml file is under the test resources folder.
1 year ago
I have an array of objects that needs to be filtered. The object structure is like below:


and the array will have 50/60 of such objects in the array like below.

I need to have something like this in order to display it on GUI. Separate out array based on their group name. Since Group names are going to be unique but each group can have multiple choices under it.

So I want to create multiple HashMaps that has key as the Group name and Value as the Name.

how can I achieve this using array functions or I need to have a separate logic to create a hashmap?

thanks,

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.



it worked with below expression.

Pattern onlyNumbers = Pattern.compile("([1-9]|[1][0-9]|[2][0-1])(\\-([1-9]|[1][0-9]|[2][0-1]))+");
7 years ago
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.
7 years ago

Carey Brown wrote:

Carey Brown wrote:"[ACFILORU](-[ACFILORU])*"



And for numbers I am using below.



Is that correct? Having "-" twice in the pattern won't confuse it right?
7 years ago

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



Which one is that?  The below?
7 years ago

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



you are right A---B is invalid. A-C is valid. The sequence of the letters does not matter as long as they are from the given list and each separated by single "-"
7 years ago

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?




that is correct. The allowed letters are "A", "C", "F", "I", "L", "O", "R", "U". they shall be separated with "-".

thanks
Pradnya
7 years ago

Carey Brown wrote:

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.

Not sure about your use of "BUT" here.

You may want to try
"[ACFILORU]+(-[ACFILORU]+)*"



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"

7 years ago

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



Ok here is what I understood after talking to Sys analysts.

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. Same is true with numbers.

thanks
trupti
7 years ago

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



Thanks,
I tried to run my unit test and I see different output when I use matcher.matches() Vs matcher.find(). What is the right method to use here?

Matcher.matches() returns false when the pattern matches but find() returns true. I am confused with these two now.

thanks
7 years ago

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:




For First and last character I am not using any regex pattern.
I use something like below.


Before checking the actual pattern.
7 years ago

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!




So "AF-RU-RE" is valid pattern, so is "OUIF-AC"

Similarly "12345-678" is valid pattern so is "202122".
7 years ago