I searched through the forums but haven't really found an answer to this. I would have thought this was a question often asked.
Is there any way to use wildcards when using the replace command?
For example, I have a list of 2000 items as shown below. I want to remove the [filename].html from each line in the list. using * as a wildcard doesn't work. Is there a way to do this?
/entertain/books/feature/aakd118books/aakd118books.html
/travel/places/feature/aakd199703_terrific/aakd199703_terrific.html
/travel/places/feature/aakd29getaway/aakd29getaway.html
should end up like this:
/entertain/books/feature/aakd118books/
/travel/places/feature/aakd199703_terrific/
/travel/places/feature/aakd29getaway/
also would there be a way to remove duplicate lines such as:
/entertain/books/feature/aakd118books/
/travel/places/feature/aakd199703_terrific/
/travel/places/feature/aakd29getaway/
/travel/places/feature/aakd29getaway/
/travel/places/feature/aakd29getaway/
I know nothing about PERL (the only close answer I found searching the forums)
Thank you!
using wildcard with Replace command
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
For a wild card you will have to use a Regex looking for:
/ followed by any character not=/ followed by .html
Try searching for this:
\/[^/]*.html
And replacing with this:
/
That should take care of the replacement part.
==============================
You could make a macro to do this Find and Replace, followed by
a select full line, then do a Find to find the current line and Mark All. Go to the first bookmark and remove the mark. Then delete all marked lines.
I think that will do it....NOTE: This is untested, just an untried concept that should be good.
Hope this helps.....good luck
===================
Subsequent editing note: I was working on this while Ed submitted his solution. As soon as mine was posted I saw his. Our Regex phrases are slightly different. Mine just deals with the trailing filename section, his treats the full line. I also wasn't aware of the sorting and delete duplicate tools. Thanks Ed. Learning every day!
/ followed by any character not=/ followed by .html
Try searching for this:
\/[^/]*.html
And replacing with this:
/
That should take care of the replacement part.
==============================
You could make a macro to do this Find and Replace, followed by
a select full line, then do a Find to find the current line and Mark All. Go to the first bookmark and remove the mark. Then delete all marked lines.
I think that will do it....NOTE: This is untested, just an untried concept that should be good.
Hope this helps.....good luck
===================
Subsequent editing note: I was working on this while Ed submitted his solution. As soon as mine was posted I saw his. Our Regex phrases are slightly different. Mine just deals with the trailing filename section, his treats the full line. I also wasn't aware of the sorting and delete duplicate tools. Thanks Ed. Learning every day!
Hope this was helpful.............good luck,
Bob
Bob