View previous topic :: View next topic |
Author |
Message |
ssjkakaroto
Joined: 09 Mar 2007 Posts: 17 Location: BR
|
Posted: Wed Nov 21, 2007 3:36 pm Post subject: Matching combination of expressions |
|
|
Hi Peter, how can I make a regex to match combinations?
Here's what I want to do:
I have the terms "USA", "Asia", "Europe" and "Africa" and I want to be able to match "USA, Africa", "Asia, USA", "Europe, Africa, Asia", "Africa" and any other possible combinations with 1, 2, 3 or 4 terms separated by a comma.
Is it possible?
Thanks a lot! |
|
Back to top |
|
|
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Wed Nov 21, 2007 4:51 pm Post subject: |
|
|
You can't define components and then match their combinations using a regular expression. This could be done using a user-defined command (plugin).
You can, however, define components in other ways and manipulate them.
For example could define the continents in the force case tables and always force them to be a certain case. Or you could look for the continents and delete them or repositionb them individually using regular expressions.
What are you trying to do? Some sample before and after names would be useful to determine the best way to handle the renaming. |
|
Back to top |
|
|
ssjkakaroto
Joined: 09 Mar 2007 Posts: 17 Location: BR
|
Posted: Wed Nov 21, 2007 7:51 pm Post subject: |
|
|
I want to remove them from the file name, the file names are completly different from one another but they all have the continents tag, for example:
"File 1 (USA).ext" -> "File 1.ext"
"Another name (Europe, Asia).ext" -> "Another name.ext"
"Yet another file (USA, Asia, Europe) (more random data).ext" -> "Yet another file (more random data).ext"
I know I can just replace each continent with nothing and them clean the leftovers but I just wanted to know if there was a more "refined" way using regex |
|
Back to top |
|
|
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Thu Nov 22, 2007 4:08 am Post subject: |
|
|
Thought about this some more.
Try this in the search column (leave the replace column blank):
[(]((Asia|USA|Europe|Africa)[, ]*)+[)]
I guess regex's can be used for combinations afterall
Cheers,
Peter. |
|
Back to top |
|
|
ssjkakaroto
Joined: 09 Mar 2007 Posts: 17 Location: BR
|
Posted: Thu Nov 22, 2007 6:08 pm Post subject: |
|
|
Wow, thanks a lot Peter!
Just out of curiosity, does it make any difference if I use \( and \) instead of [(] and [)]? |
|
Back to top |
|
|
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Fri Nov 23, 2007 7:40 am Post subject: |
|
|
There is no difference. I just used the square brackets since it made the overall expression look clearer.
Peter. |
|
Back to top |
|
|
|