Regex Quizzes
Quiz I
A.
Create a regular expression that matches class names in
Java that begin with capital letters. Examples: AmazingClass
, Sunk_Cost
,
Goon_1900
. Non-examples: notThisOne
and 50_Colors
. Class
names in Java cannot begin with a number.
B.
The sign of the devil is believed to be 666. The devil has gotten craftier, so it is now hiding its sign by putting digits between the 6’s. Write a devil-detecting regex what will not be fooled by this method of hiding.
- Examples: 666, 6666, 60606, 601020699998886.
- Nonexamples: 6623, 612376, “620 630 640”, 6!6@6x.
Match the whole integer number that contains the 666.
C.
Write a regular expression to detect lines that are at least 50 characters long.
D.
Match the numbers in these sentences.
- The precision instrument recorded a temperature of 9.782 degrees Celsius, indicating a significant increase compared to the previous day’s readings.
- The laboratory experiment yielded results with an accuracy of 3.900 units, confirming the hypothesis proposed by the research team.
- The satellite navigation system calculated the distance between two points to be 3.697 kilometers, providing crucial data for the upcoming mission.
- The sales report indicated a growth rate of 6.590%, reflecting the company’s successful marketing strategies in the past quarter.
- After meticulous calculations, the engineer determined the structural integrity of the bridge, estimating its load capacity at 2.395 tons.
Do not match the numbers in these sentences.
- The team successfully completed the project in 10 days, exceeding the initial estimate by two days due to unexpected challenges.
- The company reported a profit margin of 4%, reflecting a slight improvement compared to the previous quarter’s performance.
- After careful analysis, it was determined that the population of the city had grown by 7% over the past year, reaching a total of 213,230 residents.
- The new smartphone model boasted an impressive battery life of 8 hours, catering to the needs of users with demanding usage patterns.
- The charity event raised a total of $1,234,510, surpassing the fundraising goal and enabling support for various community initiatives.