---
title: "Regular expression to match a line that doesn't contain a word."  
description: "Regular expression to match a line that doesn't contain a word."  
author: "Utpal Vishwas"  
published: 2023-08-29  
updated: 2023-09-04  
canonical: https://www.mindstick.com/forum/159714/regular-expression-to-match-a-line-that-doesn-t-contain-a-word  
category: "c#"  
tags: ["regex", "regular expression"]  
reading_time: 1 minute  

---

# Regular expression to match a line that doesn't contain a word.

[Regular expression](https://www.mindstick.com/articles/11909/java-regex-or-regular-expression-in-java) to [match](https://www.mindstick.com/forum/159713/regex-match-attribute-in-an-html-code) a line that doesn't contain a word.

## Replies

### Reply by Aryan Kumar

Sure, here is a [regular](https://www.mindstick.com/forum/220/problem-in-regular-expression-in-javascript) [expression](https://www.mindstick.com/articles/1861/sqlite-expressions) to match a line that doesn't contain a word:

```plaintext
^[^\w\s]+$
```

The `^` metacharacter matches the beginning of the line, and the `$` metacharacter matches the end of the line. The `\w` metacharacter matches any word character, which includes letters, numbers, and the underscore character. The `\s` metacharacter matches any whitespace character.

So, this regex pattern will match any line that does not contain any word characters or whitespace characters.

For example, the following lines would be matched by this regex pattern:

```plaintext
--

12345

.
```

The following lines would not be matched by this regex pattern:

```plaintext
hello

world

this is a sentence
```


---

Original Source: https://www.mindstick.com/forum/159714/regular-expression-to-match-a-line-that-doesn-t-contain-a-word

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
