---
title: "How to Edit richtextbox to retain only words that contains underscore"  
description: "How to Edit richtextbox to retain only words that contains underscore"  
author: "Andrew Deniel"  
published: 2013-09-28  
updated: 2013-09-28  
canonical: https://www.mindstick.com/forum/1561/how-to-edit-richtextbox-to-retain-only-words-that-contains-underscore  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# How to Edit richtextbox to retain only words that contains underscore

I need some help to [define](https://yourviews.mindstick.com/audio/1110/lifestyles-choices-that-define-our-lives) how I can edit the [text](https://www.mindstick.com/blog/301635/did-people-reinvent-texting-to-express-the-full-range-of-emotions) in the richtextbox. For example, I will paste the following text on the rtextbox:\

*"[Release](https://www.mindstick.com/news/2247/apple-plans-to-release-new-macs-in-early-2023) to [user](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) USER the [roles](https://www.mindstick.com/articles/1366/membership-roles-user-profile-in-asp-dot-net): VDSF_DFGSD_DFGD_DFG_DFG_1, DFGDFG_DFGDG_DFGDFG_DFGDG_2, DFGDFG_DFGDF_DFGD_DFGDF_SADFSDF_3, SDF_SDFSD_DFGH_HJFHJ_FGDFGD_4, DFGDFU_DFGDDFGD_DFGDF_5, Q_FGDFG_6, FF_DFGDF_7"*

Then I want to edit this to keep only the text that contains the underscore("_"), and separate them in a new line, like this:

VDSF_DFGSD_DFGD_DFG_DFG_1

DFGDFG_DFGDG_DFGDFG_DFGDG_2

DFGDFG_DFGDF_DFGD_DFGDF_SADFSDF_3

SDF_SDFSD_DFGH_HJFHJ_FGDFGD_4

SDF_SDFSD_DFGH_HJFHJ_FGDFGD_5

DFGDFU_DFGDDFGD_DFGDF_6

Q_FGDFG, FF_DFGDF_7

## Replies

### Reply by Anonymous User

var text = @"Release to user USER the roles: VDSF_DFGSD_DFGD_DFG_DFG_1, DFGDFG_DFGDG_DFGDFG_DFGDG_2, DFGDFG_DFGDF_DFGD_DFGDF_SADFSDF_3, SDF_SDFSD_DFGH_HJFHJ_FGDFGD_4, DFGDFU_DFGDDFGD_DFGDF_5, Q_FGDFG_6, FF_DFGDF_7"

var words = text.Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);

```
var wordsWithUnderscores = words.Where(o => o.Contains("_")).ToArray(); foreach(var word in wordsWithUnderscores) {    Console.WriteLine(word);}
```


---

Original Source: https://www.mindstick.com/forum/1561/how-to-edit-richtextbox-to-retain-only-words-that-contains-underscore

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
