Avatar of dba123
dba123

asked on 

Keep first 150 chars of string

If I have an incoming string.  How can I use regex or something else to take that string, and keep only the first 150 chars and also exclude any HTML, line-feed, carriage returns, or tabs?

I am working on cleaning some of our descriptons and not sure the best methods to do this and how I'd go about it.

example incoming string:

In any organization, recognizing and understanding the nature and impact of toxic behaviors can provide for the ability to manage the adverse environment and mitigate the potential risks that we often face in the workplace. In Coping with Toxic Managers , Roy Lubit skillfully tackles this complicated topic by presenting the psychological aspects of toxic behaviors in a manner that is understandable and embraceable. This is not one of those 'flavor of the month' pop-psychology books-;it's truly about the science of how and why toxic people think, act, and react. Read this book and you may start looking at the people in your organization quite differently.<br><br><b>You can also purchase the individual chapters:</b><br><a href="/Product/ProductInfo.aspx?ProductID=107334">Chapter 1: Emotional Intelligence Approach to Coping with Toxic Managers and Subordinates</a><br><a href="/Product/ProductInfo.aspx?ProductID=107335">Chapter 2: Narcissistic Managers</a><br>’
C#

Avatar of undefined
Last Comment
Guy Hengel [angelIII / a3]
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

string data = "lkdaékdlakdléak léksg ag jadsfélg jaldfjg léadfjg adjfg léjadflg jaflg ";
data = data.substring(1,150);
Avatar of dba123
dba123

ASKER

thanks...but will that strip out any html, line-feeds, carriage returns, and tabs?
Avatar of dba123
dba123

ASKER

before, i was using this:

productDescription = productDescription.Substring(0,150);
Avatar of dba123
dba123

ASKER

but that wasn't stripping out any html, line-feeds, carriage returns, and tabs
Avatar of dba123
dba123

ASKER

Ok, well, in the meantime let me figure out how I can tell it to strip the HTML, line-feeds, carriage returns, and tabs.  But I won't close this until I get that fgure out....either on my side or by your help.  I'm thinking regeix in the Substring maybe?
Avatar of dba123
dba123

ASKER

or regex with substring maybe actually...
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
C#
C#

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).

98K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo