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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.