|
I've recently been pointed in the direction of RegExps for string replacement.
However, being new to both C# and RegExps, and Escape characters are giving me fits!
I've got got to remove the following characters from a string (not including the double quotes)
"`!@$%^*()+=\|[]{};:<>/?,~"
I'm having an awful time trying to evaluate what needs to be "escaped", and how many times!
ugh.
Mike Stanbrook
mstanbrook@yahoo.com
|
|
|
|
|
"^[a-z0-9_]"
the above expression should [i think] remove all characters that are not letters, numbers or the underscore, to not remove any other chars, just add them in next to the underscore.
p.s. if you dont want to keep underscores, then remove it.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
|
except the " char, which needs to be escaped with a double quote ala vb
|
|
|
|
|
Here's what I've tried:
sourceString = "123 ABC X!Y%Z}"
System.Text.RegularExpressions.Regex.Match(sourceString,"^[a-z0-9_]").ToString()
which results in: "1" (why only one character?)
I've also tried the suggestion:
System.Text.RegularExpressions.Regex.Match(sourceString,@"`!@$%^*()+=\\|[]{};:<>/?,~").ToString()
Which results in:
error: managed EE does not understand expression's syntax
Removing the @ gives a result of "" (Empty string).
Mike Stanbrook
mstanbrook@yahoo.com
|
|
|
|
|
im sorry, the ^ was meant to be inside the brackets, do this
string sourceString = "123 ABC X!Y%Z}";
Regex r = new Regex(@"[^a-z0-9]", RegexOptions.IgnoreCase);
MessageBox.Show(r.Replace(sourceString, ""));
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
|
|
Hi
First for Regex, Eric Gunnerson has a nice tool (although i have no clue how Regex works ). Look on the GotDotNet.com website under user samples.
Secondly, lets solve this problem
string badchars = @"`!@$%^*()+=\|[]{};:<>/?,~";
foreach (char bad in badchars) input = input.Replace(bad.ToString(), null );
Thats it, Hope it helps
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
|
HAHA!
That was my original approach!! It was suggested that a "better way" was using RegExps.
(My example at that time was stripping "{","-", and "}" from GUIDs.
Funny how some things come full circle!
(note: I wasn't able to find Eric's tool, but there was a RegEx Workbench that might do the trick).
Thanks.
Mike Stanbrook
mstanbrook@yahoo.com
|
|
|
|
|
MStanbrook wrote:
(note: I wasn't able to find Eric's tool, but there was a RegEx Workbench that might do the trick).
I'm a spazz. The RegEx Workbench *IS* Eric's tool.
Mike Stanbrook
mstanbrook@yahoo.com
|
|
|
|
|
Sorry , i was gonna reply but it slipped my mind, glad you made the association
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Usually, DateTimePicker control shows the date (short date), but when you pass the value of it into a datetime type variable, it has the time too. And I found the time may varies, ( I got 8/15/2002 12:00:00 am once, and 8/15/2002 12:31:21 pm the other time). Both of them are not my computer time. Can someone tell me what is going on with the time value?
|
|
|
|
|
How do I make the output of my program screen size independent? I'm writing code that prints out bitmaps, a status bar, and other stuff. It looks great on my 19" screen, but when I use anything smaller, the output is cut off. Thx,
Ralf.
ralf.riedel@usm.edu
|
|
|
|
|
First off I have found that designing with a 17" monitor to help this, however you may wish to set your resolution to 1024 x 768 which I believe is considered standard resolution. You can also resize your controls when the user maximizes their screen to keep everything standard. Most standard controls also implement the dock property which will essentially bind the control onto your form so that when the form is re-sized they stay the same distance apart from each other. Here is a link to show an example clickety [^]
Nick Parker
|
|
|
|
|
Greetings all!
I am new to programming .NET and, to be perfectly honest, I'm not really an experienced programmer. I'm an engineer that is going to have to be doing some development. So, I'm looking for the best resources available for learning/developing in .NET. Where do you go for on-line information, add-ons... those things that make development time easier? I've been hearing about "communities". Do you really use those and are they valuable, or do you spend more time in discussion forums like this? What are the best forums?
Any information would be valuable. I appreciate your time!
Jerry
|
|
|
|
|
|
i would suggest a good book.
if you're going to write windows-apps with C# then petzold's book is a good choice.
ASP and web-things are beyond my scope
:wq
|
|
|
|
|
is the whole delegate BeginInvoke/EndInvoke the best way to do asyncronous events? I'm not familiar with them.
|
|
|
|
|
|
I need to make my control such that it does not loose focus when the user clicks the tab button, how would i go about doing this. I have tried capturing it in the OnKey.. event, but the control still looses focus.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Have you just tried to reset the focus back to your control at that point?
Nick Parker
|
|
|
|
|
|
I don;t think that this is something that could be done at the control level. Using tab to move from control to control is IMHO more of a form level process. I would hate to think that a control would be allowed to grab focus and not let it go like that.
If you want to achive it at the form level just set the tabstop property of all the other controls to false and focus will have no where to go.
If you are trying to do this in a custom control you are writing then I don't think that you can.
|
|
|
|