Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • Thanks! The other solution I just found was to include the dot as the only option, as it does not need escaping inside option brackets, i.e. ^[A-Za-z0-9\ ,]+[.]1 Commented Mar 24, 2021 at 14:47
  • 1
    Yes, you can rewrite the regex to not need a backslash. Note also that space doesn't require a backslash, whether in a character set or outside. But it is needed to prevent the shell from splitting the regex. Just use single quotes unless you are sure you don't need them. Commented Mar 24, 2021 at 14:52
  • 1
    And in default Zsh, or in Bash with failglob set, the second will error out, so better just quote everything that looks like a shell glob. Also, the ERE [A-Za-z0-9\ ,] will match a backslash too. In the first command here egrep does see it because it's quoted. Commented Mar 24, 2021 at 14:59