Question

In: Computer Science

Write a regular expression, using the regular expression syntax used by lex, that matches any finite...

Write a regular expression, using the regular expression syntax used by lex, that matches any finite decimal representation of a nonnegative real number.

Solutions

Expert Solution

Regular Expression - the languages accepted by Finite automation are regular languages and these languages are easily described by simple expression called Regaualr expression ,letters of alphabet and digits are text character in regular expression.

A Character Class- is used operator. the expression

[ab]

where a,b is a strings.

the square bracket oprators are ignored used three special character \-^ are which following-

1.the escape character \ above .

2. minus character is used range

3. hat character ^ as first character after the opening square bracket, it is used complemented matches.

NOTabc [^abc]

Optional Expressions- is used optional element of an expression.

Repeated Expressions- is used multiplication(*) and addition(+).

Alternating- is used | indicate alternation (|).

Grouping- is used parentheses

Context Senitivity- lex defines of contextual grammatical rules.

  • if ^ is a first character in an expression .the expression will match at beginning of a line.
  • if $ is last charcter in an expressin. the expression is used end of a line.
  • r and s two LEX regular expression and  r/s is another LEX regular Express. it is called trailing context.

Required Answer:-

The Given Regular Expression format matches non Negative floating point numbers.

Regular expression :   ^[0-9](\.[0-9]+)?$

Matches : 1.2345 | 0.00001 | 7

Non Matches : 12.2 | 1.101 | 15.98

  


Related Solutions

Create and test a python regular expression that matches a street address consisting of a number...
Create and test a python regular expression that matches a street address consisting of a number with one or more digits followed by two words of one or more characters each. The tokens should be separated by one space each, as in 123 Main Street.
1. What is a regular expression? Write a regular expression that will detect “College” and “collegE”....
1. What is a regular expression? Write a regular expression that will detect “College” and “collegE”. 2. What is degree centrality? Create a graph of 4 vertices and compute the degree centrality of the vertices. 3. Compute internal and external community densities for a graph containing 6 nodes. You can create any graph of 6 nodes with at least 4 edges.
Write a regular expression that can represent any digit, without more than one digit or non...
Write a regular expression that can represent any digit, without more than one digit or non digit characters.
Pattern matching using python3 re module Write a regular expression that will find out all the...
Pattern matching using python3 re module Write a regular expression that will find out all the words that ends with 4 consecutive vowels at the end. Example: import re f=open("/usr/share/dict/american-english",'r') pattern='a[a-z]*d$' words=f.readlines() matchlist=[word for word in words if re.match(pattern,word)] =============================== Generate random string follow a specific pattern You will take a username and ask user for the password. User has to enter a strong password in order to create his or her account. The criteria for strong password is, a)...
write a regular expression that will, using capturing groups, find: last name first name middle name...
write a regular expression that will, using capturing groups, find: last name first name middle name (if available) student ID rank home phone work phone (if available) email program (i.e., S4040) grade Replace the entire row with comma-delimited values in the following order: first name,middle name,last name,program,rank,grade,email,student ID,home phone,work phone Example substitution string for the first student Jane,V,Quinn,S4040,SO,B,[email protected],Q43-15-5883,318-377-4560,318-245-1144,Y
Regular Expressions Assignment Write a regular expression for each of the following. Can you show output...
Regular Expressions Assignment Write a regular expression for each of the following. Can you show output please. A blank line (may contain spaces) Postal abbreviation (2 letters) for State followed by a space and then the 5-digit zip code A KU student username (Ex. lpork247) A “valid” email address (also explain how you defined “valid”) A SSN pattern (ddd-dd-dddd)
Question d) Write the regular expression statement that will match a string that starts with the...
Question d) Write the regular expression statement that will match a string that starts with the word "Warning" following by one space and then a number of any number of digits. Question e) Write the regular expression statement that will match a string that ends with the phrase "End of Report. Question f) Write the regular expression statement that will match a string that starts with the phrase "Begin Log:" then contains a collection of characters (other than newline) followed...
Q1 Write a python regular expression to match a certain pattern of phone number.             ###...
Q1 Write a python regular expression to match a certain pattern of phone number.             ### Suppose we want to recognize phone numbers with or without hyphens. The ### regular expression you give should work for any number of groups of any (non- ### empty) size, separated by 1 hyphen. Each group is [0-9]+. ### Hint: Accept "5" but not "-6" ### FSM for TELEPHONE NUMBER IS: # state:1 --[0-9]--> state:2 # state:2 --[0-9]--> state:4 # state:2 --[\-]---> state:3 #...
Write a JAVA program that reads a text file into RAM efficiently, takes a regular expression...
Write a JAVA program that reads a text file into RAM efficiently, takes a regular expression from the user, and then prints every line that matches the RE.
Write a regular expression for the language of all strings over {a,b} in which every b...
Write a regular expression for the language of all strings over {a,b} in which every b is directly preceded by a, and may not be directly followed by more than two consecutive a symbols.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT