4 votes

Fortnightly Programming Q&A Thread

General Programming Q&A thread! Ask any questions about programming, answer the questions of other users, or post suggestions for future threads.

Don't forget to format your code using the triple backticks or tildes:

Here is my schema:

```sql
CREATE TABLE article_to_warehouse (
  article_id   INTEGER
, warehouse_id INTEGER
)
;
```

How do I add a `UNIQUE` constraint?

1 comment

  1. [2]
    Comment deleted by author
    Link
    1. Deimos
      (edited )
      Link Parent
      One of the annoying things about regex is that quite a few variants exist, and almost all of them have slightly different idiosyncrasies. In sed's case, one of them is that you have to escape...

      One of the annoying things about regex is that quite a few variants exist, and almost all of them have slightly different idiosyncrasies. In sed's case, one of them is that you have to escape curly brackets with a backslash. So it would need to be:

      sed 's/[0-9]\{3\}\. //g' input.txt > output.txt
      

      That's not quite right still though - the \{3\} makes it match exactly 3 numbers, but you want to match 1-3, so it should be \{1,3\}:

      sed 's/[0-9]\{1,3\}\. //g' input.txt > output.txt
      

      (You can also call sed with -E to use "extended regular expressions" so that the backslashes aren't needed and {1,3} would have worked, but in the end it's just different idiosyncrasies)