Phyton Let Digit 0 9 Following Regular Expression Defines Digit Digit Digit Ee Digit B Q37064020

phytonLet digit be [0-9] what does the following regular expressiondefines?
a).[-]?(({digit}+)|({digit}*.{digit}+)([eE][+-]?{digit}+)?)b). [-+]?{digit}+c). Give two examples for each of the above.


Solution


a)
   The regular expression  
      [-]?(({digit}+)|({digit}*.{digit}+)([eE][+-]?{digit}+)?)

Defines a signed number or signed number represented inexponential form

    where:
   [-]? :stands for the sign which can be ‘-‘ ornothing.
   ({digit}+) : is used to denote the occurrence of oneor more digits cannot be empty hence ‘+’ sign is used.
   {digit}* : denote the presence of zero or moredigits.
   .{digit}+) : is used for representing one or morenumbers after the decimal point (.).
   ([eE][+-]?{digit}+) : denote the exponential parteither (‘e’ or ‘E’) and (‘+’ or

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.