Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ANSWER IN PYTHON Consider a simple arithmetic expression of the form operand operator operand (exactly two operands, and one operator) where the operands are either

ANSWER IN PYTHON

Consider a simple arithmetic expression of the form "operand operator operand" (exactly two operands, and one operator) where the operands are either variables or integer constants, and the operator is one of +, -, /, or *.

Variable names can only have letters (upper or lowercase), digits and underscores, but the first character cannot be a digit. There's no limit to the length of a variable name. Integer constants may have leading zeros. There may or may not be whitespaces around the operator, or around the entire expression.

Examples of legitimate expressions:

' 01*278 '

'_abc_1x2 +12'

Example of non-legit expressions:

'25/1ABC' (1ABCD is not a variable name, starts with digit)

'a & b' ('&' is not one of the 4 allowed operators)

'? a * 12 + 5 (extraneous stuff at beginning/end)

Write a regular expression to match and extract the operands and operator (in the order in which they appear) from this form of arithmetic expression. Assume that there will be a call re.findall that will apply your regular expression to a string.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions

Question

Which do you disagree with?

Answered: 1 week ago