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.

  1. The precision instrument recorded a temperature of 9.782 degrees Celsius, indicating a significant increase compared to the previous day’s readings.
  2. The laboratory experiment yielded results with an accuracy of 3.900 units, confirming the hypothesis proposed by the research team.
  3. The satellite navigation system calculated the distance between two points to be 3.697 kilometers, providing crucial data for the upcoming mission.
  4. The sales report indicated a growth rate of 6.590%, reflecting the company’s successful marketing strategies in the past quarter.
  5. 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.

  1. The team successfully completed the project in 10 days, exceeding the initial estimate by two days due to unexpected challenges.
  2. The company reported a profit margin of 4%, reflecting a slight improvement compared to the previous quarter’s performance.
  3. 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.
  4. The new smartphone model boasted an impressive battery life of 8 hours, catering to the needs of users with demanding usage patterns.
  5. The charity event raised a total of $1,234,510, surpassing the fundraising goal and enabling support for various community initiatives.
Last modified April 26, 2024: Simple quiz on regex. (9ade182)