简体   繁体   中英

How to find a string in a column that contains a lengthy “word” or set of characters

I am looking for an unusually long word or grouping of characters in a specific column of data that contains notes written by users. For example, if something like this -

I am looking for an unusuallylongwordorgroupingofcharactersina specific column

  • exists, I need to find it so I can add spaces if necessary. My question is: How do I find a word or set of characters that exceeds a certain number of characters?

The problem is that somewhere in this data, an unusually long word or grouping of characters is being parsed and causing an OutOfMemoryException , so I need to find the source and fix it.

You could use a regex in C# if the raw string fits in memory: \\w{15,} gives you words at least 15 characters in length. There are many ways to tweak this (lookahead, lookbehind, more specific character classes, etc.).

You can write a C# stored procedure that can be run against the column in question. It would split the column into an array of strings containing a word Then you can easily find the largest word in the column.

see http://msdn.microsoft.com/en-us/library/vstudio/zxsa8hkf%28v=vs.100%29.aspx

for details on how to, write install and debug a C# stored procedure in SQL Server

Using the answers given, I created a program that pulls the data and tosses each word into a list. It then pulls words of a given length (in my case, I did greater than 20 characters) and found the bad "word". Now I can fix the data.

I appreciate all your help, guys.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM