Comma problem

Report a typo

Oh, there's a really frequent problem: when the punctuation marks are placed separately from a word. Not everyone remembers that any punctuation signs must go exactly after the word. This: word . or this: word , or this: word ! are all mistakes!

As a single line of input, you will get a string with text. You need to print the message error if it contains any of the errors from above, otherwise print the message ok.

Sample Input 1:

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Sample Output 1:

ok
Write a program in Go
package main

import (
"bufio"
"fmt"
"os"
"regexp"
)

func main() {
// DO NOT modify the code block below:
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
line := scanner.Text()

// Create the regexps and write the rest of the required code below:
reDot := regexp.MustCompile(` *\.`) // whitespace + dot
reComma := ?.MustCompile(?) // whitespace + comma
reExclamation := ?.?(?) // whitespace + exclamation

onDot := reDot.MatchString(line)
onComma := ?.MatchString(line)
onExclamation := ?.?(line)

if onDot || ? || onExclamation {
fmt.Print("error")
} else {
fmt.Print(?)
}
}
___

Create a free account to access the full topic