Regular Expressions Not Working at All

A swapping-ground for Regular Expression syntax

Regular Expressions Not Working at All

Postby greyorm » Wed Sep 19, 2012 2:41 am

I'm running the 64-bit version of BRU on Windows 7. Trying to rename a directory of music files whose filenames are in the format of (as an example)
Disc Three Track 15 This is a Song.flac
to
This is a Song.flac

I've tried
^(Disc [A-Z][a-z]* Track [0-9][0-9])
which The RegEx Coach states is a valid expression, but it doesn't work.

I've tried variations of this, such as
^(Disc) ([A-Z][a-z]*) (Track) ([0-9][0-9])
and so forth, none of which work.

I finally tried just selecting the first word, but (.+) or (.*) or ([A-Z][a-z]*) won't even select the first word.

I'm stumped and frustrated. Am I doing something wrong in these expressions, or is there some technical issue underlying this instead?
greyorm
 
Posts: 1
Joined: Wed Sep 19, 2012 2:32 am

Re: Regular Expressions Not Working at All

Postby Stefan » Wed Sep 19, 2012 7:48 am

Regular Expressions works. See the Regular Expressions sub-forum, you will find there many answers.
You just have to learn how RE work. And... that an expression in it is valid doesn't say it will do what you want.
And did you read the help and selected the files in the NAME column to see in the NewName column what will happen?





.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Regular Expressions Not Working at All

Postby gligi » Wed Oct 03, 2012 11:21 am

Stefan wrote:Regular Expressions works. See the Regular Expressions sub-forum, you will find there many answers.
You just have to learn how RE work. And... that an expression in it is valid doesn't say it will do what you want.
And did you read the help and selected the files in the NAME column to see in the NewName column what will happen?
.



do you know how RE works?
simple RE such as [0-9]{4} must work but in this tool nothing worked.
gligi
 
Posts: 3
Joined: Wed Oct 03, 2012 11:18 am

Re: Regular Expressions Not Working at All

Postby Stefan » Wed Oct 03, 2012 6:53 pm

gligi wrote:
Stefan wrote:Regular Expressions works. See the Regular Expressions sub-forum, you will find there many answers.
You just have to learn how RE work. And... that an expression in it is valid doesn't say it will do what you want.
And did you read the help and selected the files in the NAME column to see in the NewName column what will happen?
.



do you know how RE works?
simple RE such as [0-9]{4} must work but in this tool nothing worked.


You have to learn how an implemented regex engine works.
[0-9]{4} alone for example means "nothing" for BRU.
You have to put the parts you want to keep into matching-group brackets
and then you can refer to them in the replacement with patterns like '\1'.
How to do this exactly depends on your file names and what you want to achieve.
Read some post in the regex sub forum to see how it works.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Regular Expressions Not Working at All

Postby gligi » Thu Oct 04, 2012 8:58 am

This is the funniest thing i ever heard :D "You have to learn how the implemented engine works" LOL

Users who use your software does not care how YOUR engine works. I used this expression in tons of software (.Net, File Editors, Online Applications etc.) and it worked EVERYWHERE. so why i should care?
This software does not even says it is invalid. It simply does not work.

But who case there are tons of similar tools like this one.

regards.
gligi
 
Posts: 3
Joined: Wed Oct 03, 2012 11:18 am

Re: Regular Expressions Not Working at All

Postby Stefan » Thu Oct 04, 2012 11:39 am

There are more then one regex engines to implement in one own application.
There are even a few regex flavors you have to differ from.
So the user have to see how an regex feature will work in each different app again.

For reference you may want to read more from one how know it better then me:

First Look at How a Regex Engine Works Internally
Knowing how the regex engine works will enable you to craft better regexes more easily.
It will help you understand quickly why a particular regex does not do what you initially expected.
This will save you lots of guesswork and head scratching when you need to write more complex regexes.
There are two kinds of regular expression engines:

http://www.regular-expressions.info/engine.html

As usual in the software world, different regular expression engines are not fully compatible with each other.
It is not possible to describe every kind of engine and regular expression syntax (or "flavor") in this tutorial.

http://www.regular-expressions.info/tutorial.html#engine



HTH?
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Regular Expressions Not Working at All

Postby gligi » Fri Oct 05, 2012 9:47 am

So which group of users are you targeting? freaks? :D

This is what most people find if they never heard about RE:
http://en.wikipedia.org/wiki/Regular_expression

the next step for most people (for most common examples):
http://www.regular-expressions.info

Common convention is one that is most used and one that is taught in the school (by the way). Surely there are different notations because everyone is smart as apple and thinks the wheel must be invented one more time or i can make thins better. And some developers and nerds may be forced to confront them.

So your idea is to make a software which should serve the people to quickly rename the files (that are mostly not to complex named) and read some articles about understanding different engines and crap?
Sure not (at least not for me). I have some files like:

4859-blabla
5783-blabla
1256-blaba

Match: [0-9]{4} Replace: empty string. basta! :)

If i can not do that this way i will use another software. As said your software does not even say this expression is not regular.
So much about this topic. I wish you much success with the software.

regards
gligi
 
Posts: 3
Joined: Wed Oct 03, 2012 11:18 am

Re: Regular Expressions Not Working at All

Postby Stefan » Fri Oct 05, 2012 11:40 am

gligi wrote:I have some files like:

4859-blabla
5783-blabla
1256-blaba

Match: [0-9]{4} Replace: empty string.



FROM:
4859-blabla
5783-blabla
1256-blaba

TO:
-blabla
-blabla
-blaba

Just use:
Remove(5)
First:4


If you really want to use regex for that simple issue, use
RegEx(1)
Match: \d{4}(.+)
Repla: \1

For BRU that means: define what you want to KEEP and not what you want to drop.
Just try it. It's not that hard and you will work it out too.


.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions