I do exercises on regular expressions. It is necessary to make up the regular expression (negative examp les).

  |  Positive |  Negative |
 | ---------- | ---------- |
 |  pit |  pt |
 |  spot |  Pot |
 |  spate |  peat |
 |  slap two |  part |
 |  respite |  |

Suppose the first part is this:

regex = r'pit|spot|spate|(slap two)|respite' 

And how to make the second and combine everything?

  • Translate the message into Russian, after all SO in Russian. - user207618

1 answer 1

As far as I understand, this is one of the usual problems for regulars.

If I am right, then you misunderstood the task. In fact, you need to create a non-regular list that lists the source words. You need a regular schedule that refers to the general laws in the first column, but not so general as to trigger words from the second column.

So, you need this:

 [\w]*[p].[t][\w]* 
  • one
    Or \w*pt\w* - Wiktor Stribiżew