Click here to Skip to main content
15,881,715 members
Home / Discussions / C#
   

C#

 
GeneralRe: VGA output in C# Pin
Dave Kreskowiak18-Nov-08 14:33
mveDave Kreskowiak18-Nov-08 14:33 
GeneralRe: VGA output in C# Pin
evertqin18-Nov-08 17:02
evertqin18-Nov-08 17:02 
GeneralRe: VGA output in C# Pin
Dave Kreskowiak18-Nov-08 17:42
mveDave Kreskowiak18-Nov-08 17:42 
AnswerRe: VGA output in C# Pin
Christian Graus18-Nov-08 11:47
protectorChristian Graus18-Nov-08 11:47 
Questionregular expression cleanup! Pin
nesfrank18-Nov-08 9:14
nesfrank18-Nov-08 9:14 
AnswerRe: regular expression cleanup! Pin
sph3rex18-Nov-08 9:34
sph3rex18-Nov-08 9:34 
AnswerRe: regular expression cleanup! Pin
carbon_golem18-Nov-08 9:54
carbon_golem18-Nov-08 9:54 
AnswerRe: regular expression cleanup! Pin
Garth J Lancaster18-Nov-08 10:17
professionalGarth J Lancaster18-Nov-08 10:17 
nesfrank wrote:
this is too slow


nesfrank wrote:
best performance


I think first of all you need to quantify what you mean here and have a way of timing a simple loop to cleanup the strings. I would have done much the same but in c++ I would have done something like :-

template <class T> 
class is_garbage: public unary_function<char, bool>
{
public:
	bool operator ()(T t) const
	{
		return ( !(isalpha( t ) || isdigit( t )));
	}
};

std::string clean(const std::string& val)
{
	string tmp = val;

   // Clean Up The String
	string::iterator it0= remove_if(tmp.begin(), tmp.end(), is_garbage<char>()); 

	// Assign To Clean String
	string result(tmp.begin(),it0);

	return result;
}


Which isnt that much different from what you've got, a bit more readable maybe Smile | :)

(NB : you would have to alter 'is_garbage' to match what you want, this is straight from my code, Ive made no attempt to replicate your issue)

Are you actually searching for strings within strings, replacing etc ? no ?? then I personally think a regex is an overkill ...

Ive copied this excerpt from John Maddock's page where he has the Regex++ library, although its been in Boost for a while now :-

"Regular expression libraries use a variety of differing algorithms all of which have their pro's and con's, which can make it hard to choose the best implementation for your purpose. This library uses an NFA algorithm which is dedicated to determining fast and accurate sub-expression matches, as well as providing support for features like back-references, which are hard to support using DFA algorithms.

People who should use this library:

Anyone who needs to use wide character strings.
Anyone who needs to search non-contiguous data.
Anyone who wants fast sub-expression matching.
Anyone who wants to customise the regular expression behaviour, or localise the library to a non-English locale.
People who should look to an alternative DFA based library:

Anyone who doesn't care about sub-expression matching, and
Wants to search only ANSI-C strings. " ref http://ourworld.compuserve.com/homepages/john_maddock/regexpp.htm[^]

'g'
AnswerRe: regular expression cleanup! [modified] Pin
Robert.C.Cartaino18-Nov-08 11:16
Robert.C.Cartaino18-Nov-08 11:16 
QuestionDataset with 6 columns, how to display only 3 in a data grid? Pin
jeweladdict18-Nov-08 9:06
jeweladdict18-Nov-08 9:06 
AnswerRe: Dataset with 6 columns, how to display only 3 in a data grid? Pin
Wendelius18-Nov-08 9:39
mentorWendelius18-Nov-08 9:39 
AnswerRe: Dataset with 6 columns, how to display only 3 in a data grid? Pin
Priya Prk18-Nov-08 9:40
Priya Prk18-Nov-08 9:40 
GeneralRe: Dataset with 6 columns, how to display only 3 in a data grid? Pin
jeweladdict18-Nov-08 9:47
jeweladdict18-Nov-08 9:47 
Questionthoughts on localizing SQL exceptions? Pin
Member 232448318-Nov-08 8:46
Member 232448318-Nov-08 8:46 
AnswerRe: thoughts on localizing SQL exceptions? Pin
Wendelius18-Nov-08 9:17
mentorWendelius18-Nov-08 9:17 
GeneralRe: thoughts on localizing SQL exceptions? Pin
Member 232448318-Nov-08 9:39
Member 232448318-Nov-08 9:39 
GeneralRe: thoughts on localizing SQL exceptions? Pin
Wendelius18-Nov-08 9:47
mentorWendelius18-Nov-08 9:47 
GeneralRe: thoughts on localizing SQL exceptions? Pin
Member 232448318-Nov-08 10:15
Member 232448318-Nov-08 10:15 
GeneralRe: thoughts on localizing SQL exceptions? Pin
Wendelius18-Nov-08 10:34
mentorWendelius18-Nov-08 10:34 
QuestionSpecifying pointer address, or something like that... Pin
boberick218-Nov-08 8:08
boberick218-Nov-08 8:08 
AnswerRe: Specifying pointer address, or something like that... Pin
Dave Kreskowiak18-Nov-08 8:21
mveDave Kreskowiak18-Nov-08 8:21 
GeneralRe: Specifying pointer address, or something like that... Pin
boberick218-Nov-08 8:37
boberick218-Nov-08 8:37 
GeneralRe: Specifying pointer address, or something like that... Pin
Paul Conrad18-Nov-08 8:43
professionalPaul Conrad18-Nov-08 8:43 
QuestionWeakreference Pin
Seetha.R18-Nov-08 6:41
Seetha.R18-Nov-08 6:41 
AnswerRe: Weakreference [modified] Pin
Lutosław18-Nov-08 6:53
Lutosław18-Nov-08 6:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.