Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2006

Tip: Looking for answers? Try searching our database.

Regex help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bryan Young - 21 Mar 2006 16:25 GMT
I want to generate a usable filename (no path, drive letter, or extension)
from strings from various sources (dates, database fields, user entry, etc).
I'm trying to use the following line and regex to replace any invalid
characters with an empty string.  However, it doesn't work.  I've tested the
expression with RegExBuddy and it says it is fine and does what I want.  I
am aware of some bugs in the .Net Framework 1.0 regarding regex, but this is
a 1.1 application.  Any help would be appreciated.

Regex.Replace(FileName,"[^\\w$%_@~`!(){}^#&-]*",string.Empty);

Bryan
Michael Bray - 21 Mar 2006 17:17 GMT
> I want to generate a usable filename (no path, drive letter, or
> extension) from strings from various sources (dates, database fields,
[quoted text clipped - 6 lines]
>
> Regex.Replace(FileName,"[^\\w$%_@~`!(){}^#&-]*",string.Empty);

Are you sure you are using the same regex in your code and your RegexBuddy?  
Because from what I see, this regex does the exact opposite of what you
want.  It takes out everything BUT the characters you have specified.  I
suggest taking out the ^ near the beginning.

Maybe you can give some examples of your input and what you get for output?

-mdb

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.