# Q1d · Five regex operators

Subject: Natural Language Processing

Exam: TEE

Reader: https://deep-learning-study-room.vercel.app/nlp/#tee/papers/legacy-r24/q1d

Canonical: https://deep-learning-study-room.vercel.app/read/nlp/tee/papers/legacy-r24--q1d/

Previous examination · complete worked answers

**Question. For word-pattern detection, explain: ^abc, abc$, [A-Z0-9], ed|ing|s, [abc].** [5 marks]

### Answer

| Pattern | Exact meaning | Positive example | Important distinction |
| --- | --- | --- | --- |
| ^abc | abc at start of the input/line under chosen mode | abcdef | Not abc anywhere |
| abc$ | abc at end | xxabc | Not starts with abc |
| [A-Z0-9] | One uppercase ASCII letter or digit | Q or 7 | One character, not the whole string |
| ed|ing|s | One of the alternatives ed, ing or s | matched ed | Without anchors this is not necessarily a suffix |
| [abc] | One a, b or c | b | Not the three-character string abc |

Use full-string matching when the entire string must satisfy a pattern; a search may find only a substring.
