Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a regular expression that matches: a) all strings that end with a dot char

ID: 3890896 • Letter: W

Question

Write a regular expression that matches:

a) all strings that end with a dot character ".", without the quotes.

b) all strings that begin with a "#" character, without the quotes.

c) all floating-point numbers using standard notation (e.g., 12.345 or –12.345). Note that matching numbers may contain any number of digits before or after the decimal point.

d) all floating-point numbers using scientific notation (e.g., 1.234e+5 or –1.234E–5). Again, matching numbers may contain any number of digits before or after the decimal point.

Explanation / Answer

a) pattern = ^[a-zA-Z0-9]+.$

b) pattern = ^#[a-zA-Z0-9]+$

c) pattern = [+-]?([0-9]*[.])?[0-9]+

d) pattern = [+-]?([0-9eE]*[.])?[0-9]+[+-]?[0-9]+

**Test this regex using java or C#.

**Comment for any further queries

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote