471,330 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

What classes handle regular expressions?

I'll be working with regular expressions and
hopeful as i am, i count on that there are
tools ready to handle e.g. file operations
using regular expressions.

Please tell me it's so and give me a pointer
to what classes/packages to aim at.

--
Regards
Konrad Viltersten
Jul 22 '08 #1
6 1115
This depends on the work you will be doing. The regular expression classes in
..NET are in the System.Text.RegularExpressions namespace. Most prominantly
its hte RegEx class.
These will allow you to match Regular expressions to text. You would need to
code the file operations around this functionality.
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"K Viltersten" wrote:
I'll be working with regular expressions and
hopeful as i am, i count on that there are
tools ready to handle e.g. file operations
using regular expressions.

Please tell me it's so and give me a pointer
to what classes/packages to aim at.

--
Regards
Konrad Viltersten
Jul 22 '08 #3
This depends on the work you will be doing. The regular expression classes
in
.NET are in the System.Text.RegularExpressions namespace. Most prominantly
its hte RegEx class.
These will allow you to match Regular expressions to text. You would need
to
code the file operations around this functionality.
Oh, right, i ment to do the file operations myself, of course. As
long as i get the strings right, i can do the rest easily. Thanks.

I've been browsing and i'm getting an impression that what
some people refer to as regular expressions, isn't fully
well-defined. It seems that Microsoft uses a different pattern
to denote the regularities in the expressions that some
other system suggest. Is it true?

--
Regards
Konrad Viltersten
Jul 22 '08 #4
K Viltersten wrote:
I've been browsing and i'm getting an impression that what
some people refer to as regular expressions, isn't fully
well-defined. It seems that Microsoft uses a different pattern
to denote the regularities in the expressions that some
other system suggest. Is it true?
Reasonable well defined. There are some differences among
implementations. But they are mostly in the advanced stuff - the
basic stuff is the same everywhere.

Arne
Jul 22 '08 #5
K Viltersten wrote:
I'll be working with regular expressions and
hopeful as i am, i count on that there are
tools ready to handle e.g. file operations
using regular expressions.

Please tell me it's so and give me a pointer
to what classes/packages to aim at.
For inspiration see below.

Arne

======================================

using System;
using System.IO;
using System.Text.RegularExpressions;

namespace E
{
public static class MyExtensions
{
public static FileInfo[] GetFilesRegExp(this DirectoryInfo di,
string pat)
{
Regex re = new Regex(pat);
return Array.FindAll(di.GetFiles(), (f) =>
re.IsMatch(f.Name));
}
}
public class Program
{

public static void Main(string[] args)
{
Regex re = new Regex(@"^[Zz].*$");
DirectoryInfo di = new DirectoryInfo(@"C:\");
FileInfo[] f1 = Array.FindAll(di.GetFiles(), (f) =>
re.IsMatch(f.Name));
foreach(FileInfo f in f1)
{
Console.WriteLine(f.FullName);
}
FileInfo[] f2 = di.GetFilesRegExp(@"^[Zz].*$");
foreach(FileInfo f in f2)
{
Console.WriteLine(f.FullName);
}
Console.ReadKey();
}
}
}
Jul 23 '08 #6
>I'll be working with regular expressions and
>hopeful as i am, i count on that there are
tools ready to handle e.g. file operations
using regular expressions.

Please tell me it's so and give me a pointer
to what classes/packages to aim at.

For inspiration see below.
<snip>

For all it's worth, i'm inspired! ;)
Thanks!

--
Regards
Konrad Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.
Jul 23 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by MJ | last post: by
4 posts views Thread by GenoJoe | last post: by
2 posts views Thread by Sehboo | last post: by
4 posts views Thread by Egyd Csaba | last post: by
7 posts views Thread by Billa | last post: by
20 posts views Thread by Asper Faner | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.