I'm trying to find two cases in a test string.

_Large and jpeg

Here is my string :

E:\Music Test Folder\Lamb of God\Wrath\AlbumArt_{F5969BAB-11BC-49E0-9B56-B6E9654204B7}_Large.jpeg

And here is my expression:

Match large = Regex.Match(file, @"^.*(_Large).(jpeg)$/i", RegexOptions.IgnoreCase);

I cannot get a match.

What am I doing wrong?

I dont think you need the '/i' at the end when you already have RegexOptions.IgnoreCase . The whole p

Try this out.

Match large = Regex.Match(file, @"^.*(_Large).(jpeg)$", RegexOptions.IgnoreCase);

I've tried that. Still not working.

Can you post the whole code?

what is the file variable holding?

The variable is holding a file path string

Here is the code:

 public void processFiles(string path)
        {
            string[] files;
            string[] directories;

            files = Directory.GetFiles(path);
            foreach (string file in files)
            {
                ID3Reader r;
                Match m = Regex.Match(file, @"^.*\.(mp3|mpg)$", RegexOptions.IgnoreCase);
                if (m.Success)
                {
                    r = new ID3Reader(file);

                    string _songName = c.toString(r.getSongName());
                    string _artistName = c.toString(r.getArtistName());
                    string _albumName = c.toString(r.getAlbumName());
                    string _songPath = r.getSongPath();

                    Dispatcher.Invoke((Action)(() => artistName.Content = _artistName));
                    Dispatcher.Invoke((Action)(() => songName.Content = _songName));
                    Dispatcher.Invoke((Action)(() => albumName.Content = _albumName));

                    q.insertSong(_artistName, _albumName, _songName, _songPath);
                }
                Match small = Regex.Match(file, @"^.*(_Small).(jpeg)$", RegexOptions.IgnoreCase);
                if (small.Success)
                {
                    continue;
                }
                Match large = Regex.Match(file, @"^.*(_Large).(jpeg)$",  RegexOptions.IgnoreCase);
                if (large.Success)
                {

                }
            }
            directories = Directory.GetDirectories(path);
            foreach (string directory in directories)
            {
                processFiles(directory);
            }
        }

I'm getting a match here, not sure why you aren't (using your example from the first post and the code from the last post).

Maybe the problem isn't the match but the code once there is a match. What you submitted doesn't show any code.

I can't submit anymore code. I think my code clearly states what I'm trying to accomplish. The file variable is passed a string with a absolute path. I am trying to determine if it is a small image or a large image. I have been trying to get my regular expression to test the string. So far I have had no luck other than getting a online expression evaluator (Rubular) to confirm my expression. WPF on the other hand does not accept my expression. I am hoping someone can help me figure out why. Thanks.

Put a breakpoint at line 31 and see what is actually in file.

Just a thought. Are the image files really saved as '.jpeg'? I've looked on my system and all the album art ones I can find are '.jpg'. If this is the case, on yours too, your expression won't find anything.

In looking at your code, I can't help wondering if you're trying to use a sledge hammer to crack a walnut. consider the following. It does the same thing with fewer line of code.

            foreach (string file in Files)
            {
                if(file.Contains(".mp3")||files.Contains(".mpg"))
                {
                    r = new ID3Reader(file);
                    string _songName = c.toString(r.getSongName());
                    string _artistName = c.toString(r.getArtistName());
                    string _albumName = c.toString(r.getAlbumName());
                    string _songPath = r.getSongPath();
                    Dispatcher.Invoke((Action)(() => artistName.Content = _artistName));
                    Dispatcher.Invoke((Action)(() => songName.Content = _songName));
                    Dispatcher.Invoke((Action)(() => albumName.Content = _albumName));
                    q.insertSong(_artistName, _albumName, _songName, _songPath);
                }
                else if(file.Contains("_Small.jpg"))
                {

                }
                else if(file.Contains("_Large.jpg"))
                {

                }
            }

@tinstaafl. The file was saved as .jpg

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.