CodeGym /Courses /Java Multithreading /Practice using StringTokenizer and String.replace

Practice using StringTokenizer and String.replace

Java Multithreading
Level 2 , Lesson 13
Available
Practice using StringTokenizer and String.replace - 1

"Not so fast. Do a couple of tasks, and then you'll have mastered it."

12
Task
Java Multithreading, level 2, lesson 13
Locked
StringTokenizer
Using a StringTokenizer, split the query into parts using the String delimiter. For example, getTokens("level22.lesson13.task01", ".") returns a string array {"level22", "lesson13", "task01"}
12
Task
Java Multithreading, level 2, lesson 13
Locked
Changing the encoding
The first parameter of the main method is the name of a file encoded in Windows-1251. The second parameter of the main method is the name of a file to which you need to write the contents of the first file, but encoded in UTF-8.
24
Task
Java Multithreading, level 2, lesson 13
Locked
Phone number verification
The checkPhoneNumber method should check whether the phoneNumber argument is a valid phone number. Verification criteria: 1) if the number starts with '+', then it must contain 12 digits; 2) if the number starts with a digit or opening parenthesis, then it must contain 10 digits.
Comments (9)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
matemate123 Level 50, Kraków, Poland
22 March 2023
Can be helpful: https://codegym.cc/groups/posts/regex-java
阿狼 Level 32, Zhengzhou, China
8 July 2022
d30
Jomar Tayactac Level 5, Winnipeg, Canada Expert
28 June 2022
For phone number verification, don't forget to check if the phone number is null or empty.
18 December 2021
针对开头匹配数字长度 phoneNumber.matches("^+.*") && phoneNumber.replaceAll("\\D","").toCharArray().length!=12
aijo Level 30, Germany, Germany
29 April 2022
funnily, I used regex in the second part, but not the first (exactly opposite to you):

if (phoneNumber.startsWith("+")) return phoneNumber.replaceAll("[\\D]","").matches("[\\d]{12}");
Adam Level 25, London, United Kingdom
20 October 2020
Regex is awesome but makes my brain ache still :)
Lawson Level 29, Lagos, Nigeria
13 September 2020
The task are getting deadlier by the day
MaGaby2280 Level 41, Guatemala City, Guatemala
30 June 2020
Really hard ones... try to think the easiest and simplest way possible!
Hossein Shams Level 1, Atlanta, United States
3 November 2019
Love RegEx