which one is appropriate to use for this task? Regex or URL class?
Should i use Regex or URL?
Under discussion
Comments (10)
- Popular
- New
- Old
You must be signed in to leave a comment
Jurij Thmsn
23 June 2021, 07:53
I think you can solve this the way which fits you best.
Personally, I used String methods (.split(), .replaceAll() etc) as well as StringBuilder. This may not be the most elegant solution, but a very good practice and you also don't need to learn about the URL class etc.
Check out the discussion of the task, a lot of people wrote there.
0
John
23 June 2021, 08:01
Thank you so much ;)
0
John
23 June 2021, 08:01
i think you send me a wrong link
0
Jurij Thmsn
23 June 2021, 09:34
I don't think so. Just scroll down, there are many comments regarding the task. Or you just click the "Discuss the task" button (in-browser: speech bubble, IntelliJ: " i " button)
0
John
23 June 2021, 12:10
Thank you ;)
0
John
23 June 2021, 12:10
im also stuck in debugging thing, im confused on using it :(
0
Guadalupe Gagnon
23 June 2021, 13:27
I solved it the way that Jurij did. Some tips:
This task is very simple if you just break it down. There are only 2 symbols you need to pay attention then a third symbol if the String equals "obj", the rest is all fluff/filler/unimportant:
*fluff*?StringArgNotObj=*fluff*&StringArgNotObj&obj=value
You just need to pay attention to the ?(question mark), each argument following that is not "obj",&(ampersand), and then when the argument is "obj" you will have to get the value on the right of the =(equals sign). That is the entire task. The fluff could be only a couple characters long of thousands of characters long, it does not matter though because it is unimportant in all cases. Just be sure to grab the value after the = if you find an "obj".
+1
John
24 June 2021, 00:52
Thanks for the tip Guadalupe, how about the debugging mode? i already knew about your debugging way and tried it already, in which you declare e flag set to true and a hardcoded input. but the one codegym teach is what im confused of im having a hard time undertsanding the debugging option in intelli j
0
John
24 June 2021, 01:51
im so exhausted with this last task. i already read about the Stringbuilder and Stringbuffer class and somehow understand the functionality. but still cant think of a logic that will finish this task :(
0
Guadalupe Gagnon
24 June 2021, 16:14
You don't need those if they are too difficult at this point, just using the String class is acceptable. Think of what you need to do. Here are the main steps for this task without any code:
1) find the question mark (?) and remove everything to the left of it including the mark. This will leave you with only the part of the original String that the task needs
2) now you want to break that String up into smaller Strings, the break point being the ampersands (&). So if you had generic strings separated by the & symbols:
str1&str2&str3&str4&str5&str6
the result would be [str1, str2, str3, str4, str5, str6]
3) for each of those you want to:
a) identify if the argument is "obj", if true then save everything to the right of the equals sign
b) regardless of the result of 'a', print to the screen everything left of the "=", or everything if no equals sign is present
4) send everything saved for step 3a when "obj" is found to the proper alert(method). be sure to test if it is a double or not.
As for the debugger in IntelliJ... of course it is difficult, you have never used something similar before. If I had understood how to use it in the first place I would have never created my own way to simplify debugging. Keep trying to use it and over time you will get better at it.
+3