|
I have tried the following with no luck. I do not understand why NET RegEx does not handle this RegEx pattern. The pattern checks out fine in Regulator.
string testString = @"c:\temp\test.wav";
// get file extension
string pattern;
pattern = @".+\.[^.]+$";
System.Text.RegularExpressions.Regex regEx;
regEx = new System.Text.RegularExpressions.Regex(pattern);
System.Text.RegularExpressions.MatchCollection matchList;
matchList = regEx.Matches(testString);
string foundString;
foundString = matchList[0].Value;
// the output will be the same as testString: c:\temp\test.wav.
// the desired result is 'wav'
Console.WriteLine(foundString);
Happy Holidays
-- modified at 8:48 Friday 23rd December, 2005
|
|
|
|
|
hi redfish34,
try something like this:
pattern= @"(?<filename>.+)\.(?<extension>[^.]+)$";
then you can access the extension by matchList[0].Groups["extension"].Value
/cadi
24 hours is not enough
|
|
|
|
|
I got a "Unrecognized grouping construct" in both Regulator and VS 2003. But thanks for the effort!
The RegEx i am using came direct from http://www.regexlib.com/ and checks out fine in Regulator, so i do not understand why the NET 1.1 RegEx is not liking it. Maybe this is a bug with NET and i will be forced to parse the extension by hand. It is no big deal, i just don't like all these Microsoft headaches.
|
|
|
|
|
sorry, the braces got lost...
pattern= @"(?<name>.+)\.(?<extension>[^.]+)$";
(i should use preview before posting...)
/cadi
24 hours is not enough
|
|
|
|
|
Your mentioning of groups got me thinking. I tried the following code with my RegEx pattern:
foundString = matchList[0].Groups[1].ToString();
It returns the file extension "wav", which is what i wanted. I guess when one uses a capture expression in a RegEx then one must use groups to access the matches.
Thanks
|
|
|
|
|
there is one other solution using a non capturing group:
(?<=.+\.)[^.]+$
this will have only the extension in the resulting match.
/cadi
24 hours is not enough
|
|
|
|
|
|
you could skip regex and use FileInfo.
FileInfo fi = new FileInfo(filename);
string ext = fi.Extension();
Just an idea. Not sure what would be faster tho.
|
|
|
|
|
I did not notice the "Extension" property of the FileInfo object. That is definitely a better solution. Well, at least i got some RegEx practice from all this. I will be using RegEx extensively in my next project.
|
|
|
|
|
|
How Can I take backup of all table(with data) and store in XML file
Its Urgent plz?
|
|
|
|
|
I dont know if it's possible!
Maybe you should use a serializable file to save the objects..
VentoEngine corp.
Program your life ^^
|
|
|
|
|
You can pull the data you want to back up into a DataSet and then use the GetXml method to convert the Data into Xml.
|
|
|
|
|
Is this possible for entire database.
|
|
|
|
|
Technically yes it is possible. I don't know if its the most efficient solution though. Basically you would have to create a DataTable for each table in your database by quering the records you want to backup and then add the DataTable to the DataSet before you call the GetXml() method.
|
|
|
|
|
But, How to bind the whole database table in dataset, Can u give me any idea or any link...
|
|
|
|
|
Can can we take backup(programatic)of database as well as data of tables and store in XML file
|
|
|
|
|
|
The solution to this problem ( what I understand is):
Go to lable’s property box, then find (DataBindings) tree on the top, open its tree, there you will se (Advanced) property. Select it and click the button on right. It will open a dialog box for “Formatting and Advanced Settings”. Here you will get a combobox naming “Binding”. So from here you can databind your label control.
Sheel Gohe
|
|
|
|
|
im using visual studio 2005 and im writing aspnet
in label properties databindings never been
|
|
|
|
|
Sorry buddy, i thought you were building windows application.
Sheel Gohe
|
|
|
|
|
Hi all,
I am designing an app which has its FrameBorderStyle set to none. As a result, it is not possible to get the System menu by right clicking on the application icon in the taskbar.
Can anyone tell me how to get around this problem.
Thanks in advance.
*** Who said nothing is impossible? I have been doing it for a long time ***
|
|
|
|
|
Printing is sent from an application ( notepad,wordpard,pdf file etc) .Before print the data I want to add the purpose of print to the print job through my application in C#.
Can I fire an event in C# before printing, sent by any application?
If possible give me some idea ,or what book /site to follow to fire event and add data to the printing job.
|
|
|
|
|
I am using C# for an application project. I am looking for the best grid tool.
Anyone can give me suggestion. Lisenced or free tool is OK for me.
Thank you.
Could you please email to me: tubaphuoc@yahoo.com.
Phuoc Tu
|
|
|
|
|
Hi there,
just googling and then find out which one is the best fit for you...
<< >>
|
|
|
|