Question

Let digit be [0-9] what does the following regular expression defines in Unix? a). [-]?(({digit}+)|({digit}*\.{digit}+)([eE][+-]?{digit}+)?) b)....

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



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

a) [-]?(({digit}+)|({digit}*\.{digit}+)([eE][+-]?{digit}+)?)
Let me explain in parts -
[-]? -> 0 or 1 occurrence of '-'
({digit}+)|({digit}*\.{digit}+) ->  {digit}+ -> 1 or more occurrence of digits
| -> OR
  {digit}*\.{digit}+ -> 0 or more occurrence of digits followed by a '.' and one or more occurrence of digits
([eE][+-]?{digit}+)? -> [eE][+-]? -> 'e' or 'E' followed by either (+ or -)(0 or 1 occurrence)
{digit}+ -> 1 or more occurrence of digits
? -> 0 or 1 occurrence of ([eE][+-]?{digit}+)
Example - 1, .9, 0.2, 7e9, 7e-9, 7e+9, 0.2E+9
Basically, it is representation in exponential form with the e part may or may not exist

b) [-+]?{digit}+
It is simply representation of integers that is (+ or -)(0 or 1 occurrence) followed by at least 1 digit.
Example - 1,+1,-1

Add a comment
Know the answer?
Add Answer to:
Let digit be [0-9] what does the following regular expression defines in Unix? a). [-]?(({digit}+)|({digit}*\.{digit}+)([eE][+-]?{digit}+)?) b)....
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
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