Create sed regular expressions that satisify the following • No more than one sp
ID: 3756999 • Letter: C
Question
Create sed regular expressions that satisify the following
• No more than one space between tokens.
• No trailing whitespace after a line.
• Binary operators should always surrounded by a single space on either side (including assignment and Boolean). Only the following operators must be accounted for: +, -, *, /, =, ==, <=, >=, <, >.
• Conditions should not have whitespace immediately inside of the parentheses.
• The program should not modify spaces which are leading, expanded tabs.
• Comments should be left alone. You may assume comments (single- and multi-line) will not appear on lines with source code
Explanation / Answer
Ans 1-sed -E 's/ s[a-zA-Z]s//g'
Ans 2- sed -E 's/.s /. /g'
Ans 3- sed -E 's/[ +, -, *, /, =, ==, <=, >=, <, >]s//g'
Ans 4- sed -E 's/{s/{/g'
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.