In: Computer Science
Write a regular expression, using the regular expression syntax used by lex, that matches any finite decimal representation of a nonnegative real number.
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.
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