Welcome Guest.   Make a donation to an author on the site November 27, 2014, 04:42:18 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Your Support Funds this Site: View the Supporter Yearbook.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: DONE: Regex Sorter  (Read 10746 times)
Shardnax
Participant
*
Posts: 8

View Profile Give some DonationCredits to this forum member
« on: March 16, 2011, 11:40:10 AM »

I maintain the master list and help with maintaining the master list of threads on some sites, alphabetizing them is probably the most troublesome thing to do, on with my request:

What I'm looking for is a text editor like notepad, or an external program to alphabetize text files based on the name that is contained in the brackets of a url tag in BBCode.
Thread Title
*url=http://www.examplesite.com/showthread.php?t=thread]Thread Title 2[/url*

If I posted this incorrectly please tell me, and how I can fix it. Many thanks to anyone that decides to pick up this request.
« Last Edit: March 19, 2011, 08:26:04 PM by mouser » Logged
timns
Supporting Member
**
Posts: 1,209



Veni, vidi, debuggi

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: March 16, 2011, 11:57:00 AM »

Doesn't sound too bad at all - if no-one picks this up by March 28th, I'll do this one.

How I would do this: a bit of Java that reads a file and applies a regex to find the sort criteria in each line.

Say something like the following: ^.*?=thread\](.*?)\[.*?$

Sort on \1

Rewrite

This would actually be very easy to make configurable, possibly quite handy for other uses.
Logged

Shardnax
Participant
*
Posts: 8

View Profile Give some DonationCredits to this forum member
« Reply #2 on: March 16, 2011, 12:02:37 PM »

Doesn't sound too bad at all - if no-one picks this up by March 28th, I'll do this one.

How I would do this: a bit of Java that reads a file and applies a regex to find the sort criteria in each line.

Say something like the following: ^.*?=thread\](.*?)\[.*?$

Sort on \1

Rewrite

This would actually be very easy to make configurable, possibly quite handy for other uses.

Feel free to add extra functionality as you want, all I want is the url sorting tongue. Thanks for offering so quickly.
Logged
skwire
Global Moderator
*****
Posts: 4,158



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #3 on: March 16, 2011, 02:05:16 PM »

I have this pretty much done.  Would you mind providing a list of valid URLs and your expected sorting of them for testing purposes?  If they're sensitive links, feel free to PM the list.
Logged

timns
Supporting Member
**
Posts: 1,209



Veni, vidi, debuggi

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #4 on: March 16, 2011, 02:49:58 PM »

skwire, is it a general solution? Since I can think of a couple of uses for this sort of sorting. If it's specific to sorting URLs I may still have a crack at it later.
« Last Edit: March 16, 2011, 02:50:19 PM by timns; Reason: crack a tit -> crack at it » Logged

skwire
Global Moderator
*****
Posts: 4,158



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #5 on: March 16, 2011, 02:53:27 PM »

Yeah, it's general.  Paste a list, provide a needle regex and sort.
Logged

mouser
First Author
Administrator
*****
Posts: 33,700



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #6 on: March 16, 2011, 03:57:55 PM »

When i saw request i had same exact thoughts as timns (clever hobbit!) -- to let people specify how to extract the sort criteria using a regex.  Very smart.  I may steal this idea and put it in my Clipboard Help+Spell sorting options as well.
Logged
Shardnax
Participant
*
Posts: 8

View Profile Give some DonationCredits to this forum member
« Reply #7 on: March 16, 2011, 08:58:37 PM »

I have this pretty much done.  Would you mind providing a list of valid URLs and your expected sorting of them for testing purposes?  If they're sensitive links, feel free to PM the list.

Sent, I was off by the time you posted this or I would have responded sooner.
Logged
rgdot
Supporting Member
**
Posts: 1,665


View Profile WWW Give some DonationCredits to this forum member
« Reply #8 on: March 16, 2011, 09:44:25 PM »

I would be interested in this, nice idea. Thanks Shardnax, skwire and timns.
Logged
skwire
Global Moderator
*****
Posts: 4,158



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #9 on: March 16, 2011, 10:12:58 PM »

Give this a shot:  http://skwire.dcmembers.com/apps/snacks/RegExTextSorter.zip

The app is still early so nothing is saved, etc.  The RegEx needle dropdown does have two entries in it, though, to help you out; the first one ought to work for your URLs.  At this point, you can only use one back-reference.

Here are some screenshots:



« Last Edit: March 17, 2011, 07:12:58 AM by skwire » Logged

Shardnax
Participant
*
Posts: 8

View Profile Give some DonationCredits to this forum member
« Reply #10 on: March 16, 2011, 11:04:17 PM »

The text between the ][ brackets is what's showing up in the match box.

Edit:
Sort wasn't working at first, it is now. It's quite usable as is, the only issue is this
It should be in the same order as on top.
« Last Edit: March 16, 2011, 11:14:10 PM by Shardnax » Logged
skwire
Global Moderator
*****
Posts: 4,158



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #11 on: March 17, 2011, 12:08:33 AM »

It should be in the same order as on top.

The screenshot is correct.  In other words, "Example 2" should come before "Examplel" in an alpha sort.  Please redownload the zip file.  I fixed an issue where any trailing newlines would negate any output.
Logged

Shardnax
Participant
*
Posts: 8

View Profile Give some DonationCredits to this forum member
« Reply #12 on: March 17, 2011, 10:22:16 AM »

I feel dumb, I didn't even notice the l there.

Got it downloaded, it sorts the text in the same order as the source.
« Last Edit: March 17, 2011, 10:47:34 AM by Shardnax » Logged
skwire
Global Moderator
*****
Posts: 4,158



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #13 on: March 18, 2011, 03:27:41 PM »

Shardnax...do we call this one done?
Logged

Shardnax
Participant
*
Posts: 8

View Profile Give some DonationCredits to this forum member
« Reply #14 on: March 19, 2011, 11:48:02 AM »

Certainly, thanks again for being willing to make it cheesy. This is gonna save me a lot of time.
« Last Edit: March 19, 2011, 11:51:06 AM by Shardnax » Logged
skwire
Global Moderator
*****
Posts: 4,158



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #15 on: March 19, 2011, 08:06:14 PM »

Fantastic.  I'm glad to help.
Logged

mouser
First Author
Administrator
*****
Posts: 33,700



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #16 on: March 30, 2011, 05:57:36 AM »

I have a feature request that would really come in handy for me -- an option to remove duplicates after sorting, but do duplicate checking again only of regex match group.

(i.e. the whole line doesn't have to be the same to be removed, just the regex match part).
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.035s | Server load: 0.1 ]