View previous topic :: View next topic |
Author |
Message |
wolfman6
Joined: 07 Jul 2009 Posts: 3
|
Posted: Tue Jul 07, 2009 2:07 am Post subject: How to delete all characters from a bracket on |
|
|
I have some files I copied from my web browser that are named 'filename[1]200905090513145.jpg' etc. Also have some that just have 'filename[1].*'. I would like to delete everything from the first bracket on. I found a similar post from someone to delete everything after a '-' and tried to modify it with a [, but I get an error saying that it's an unexpected end of syntax or something like that.
Please help!
Thanks
wolfman6 |
|
Back to top |
|
 |
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Tue Jul 07, 2009 4:18 pm Post subject: |
|
|
Hi,
Just put '\[.*' in the search column of the first row (don't inlcude the single quotes). leave the replace column of that row empty.
That will delete everything from the first bracket onwards.
Note that since brackets are special characters in regualr expressions you needed to escape them by preceeding them with a backslash.
Hope that helps.
Peter. |
|
Back to top |
|
 |
wolfman6
Joined: 07 Jul 2009 Posts: 3
|
Posted: Wed Jul 08, 2009 2:50 am Post subject: How to delete all characters from a bracket on |
|
|
Hi,
Thanks for replying. It looks like it will work, but it will delete the file extension, too and I don't want to do that - only the prefix.
How do I modify to leave the extension alone?
Thank you!! |
|
Back to top |
|
 |
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Wed Jul 08, 2009 1:33 pm Post subject: |
|
|
Try '(?E)\[.*'
- again don't include the single quotes.
The preceeding '(?E)' will make the regex engine skip the extension.
Peter. |
|
Back to top |
|
 |
wolfman6
Joined: 07 Jul 2009 Posts: 3
|
Posted: Wed Jul 08, 2009 1:37 pm Post subject: |
|
|
Works great! Thank you so much for your help! |
|
Back to top |
|
 |
|