Question

Write a regular expression that matches: a) all strings that end with a dot character ".",...

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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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

Add a comment
Know the answer?
Add Answer to:
Write a regular expression that matches: a) all strings that end with a dot character ".",...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Regular Expressions Write a regular expression for numeric constants in C. These are octal, decimal, or...

    Regular Expressions Write a regular expression for numeric constants in C. These are octal, decimal, or hexadecimal integers, or decimal or hexadecimal floating-point values. An octal integer begins with 0, and may contain only the digits 0-7. A hexadecimal integer begins with 0x or 0X, and may contain the digits 0-9 and a/A-f/F. A decimal floating-point value has a fractional portion (beginning with a dot) or an exponent (beginning with E or e). Unlike a decimal integer, it is allowed...

  • Regular expressions, DFA, NFA, grammars, languages Regular Languages 4 4 1. Write English descriptions for the...

    Regular expressions, DFA, NFA, grammars, languages Regular Languages 4 4 1. Write English descriptions for the languages generated by the following regular expressions: (a) (01... 9|A|B|C|D|E|F)+(2X) (b) (ab)*(a|ble) 2. Write regular expressions for each of the following. (a) All strings of lowercase letters that begin and end in a. (b) All strings of digits that contain no leading zeros. (c) All strings of digits that represent even numbers. (d) Strings over the alphabet {a,b,c} with an even number of a's....

  • The phrase regular expressions, also called regexes, is often used to mean the specific, standard textual...

    The phrase regular expressions, also called regexes, is often used to mean the specific, standard textual syntax for representing patterns for matching text, as distinct from the mathematical notation described below. Each character in a regular expression (that is, each character in the string describing its pattern) is either a metacharacter, having a special meaning, or a regular character that has a literal meaning. For example, in the regex a., a is a literal character which matches just 'a', while...

  • NEED ASAP PLEASE WILL GIVE GOOD RATE RIGHT AWAY FOR ALL ANSWERS! A) write a regular...

    NEED ASAP PLEASE WILL GIVE GOOD RATE RIGHT AWAY FOR ALL ANSWERS! A) write a regular expression (use regular expression syntax) to represent a floating point number, where the number begiywith an optional sign followed by at least 1 digit , followed by a decimal point and one or more other digits. Ex: -33.9 , +1.11919, 1.0 B) draw a dfsa to represent the regular expression

  • Write a python program and pseudocode The Program Using Windows Notepad (or similar program), create a...

    Write a python program and pseudocode The Program Using Windows Notepad (or similar program), create a file called Numbers.txt in your the same folder as your Python program. This file should contain a list on floating point numbers, one on each line. The number should be greater than zero but less than one million. Your program should read the following and display: The number of numbers in the file (i.e. count them) (counter) The maximum number in the file (maximum)...

  • Using loops with the String and Character classes. You can also use the StringBuilder class to...

    Using loops with the String and Character classes. You can also use the StringBuilder class to concatenate all the error messages. Floating point literals can be expressed as digits with one decimal point or using scientific notation. 1 The only valid characters are digits (0 through 9) At most one decimal point. At most one occurrence of the letter 'E' At most two positive or negative signs. examples of valid expressions: 3.14159 -2.54 2.453E3 I 66.3E-5 Write a class definition...

  • This question deals with NFAs, DFAs, and regular expressions. (a) Using only the symbols described in...

    This question deals with NFAs, DFAs, and regular expressions. (a) Using only the symbols described in the lecture slides, write a regular expression that describes all strings over the alphabet Σ = {0,1} that are at are at least four bits long and begin and end with the same bit. (b) Draw a DFA, that accepts strings strings over the alphabet Σ = {0, 1} such that if you read the string from left to right, the difference between the...

  • In mathematics, a rational number is any number that can be expressed as the quotient or...

    In mathematics, a rational number is any number that can be expressed as the quotient or fraction p/q of two integers, p and q, with the denominator q not equal to zero. Since q may be equal to 1, every integer is a rational number. Define a class that can represent for a rational number. Use the class in a C++ program that can perform all of the following operations with any two valid rational numbers entered at the keyboard...

  • Use the Python “re” module to do the following: 1. Write a regular expression pattern that matche...

    Use the Python “re” module to do the following: 1. Write a regular expression pattern that matches string “March 1, 2019, Mar 1, 2019, March First, 2019, March First, 19”. No credit for not using special characters: “*,+,?, | and etc” to do the matching. 2. Write a regular expression pattern that matches strings representing trains. A single letter stands for each kind of car in a train: Engine, Caboose, Boxcar, Passenger car, and Dining car. There are four rules...

  • MATLAB QUESTION function Huge_Add = huge_add(number1,number2) sum= number1 + number2; sprintf(' %+5.2d',sum) end 3. Write function...

    MATLAB QUESTION function Huge_Add = huge_add(number1,number2) sum= number1 + number2; sprintf(' %+5.2d',sum) end 3. Write function called huge add that adds together two positive integers of any length specified as strings using decimal notation. The single output argument is the result and it is a string as well. The inputs and output must contain digits only; no commas, spaces or any other characters are allowed. If any of these assumptions are violated by the input, the function returns the number-1.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT