Search found 13 matches

by CobraCards
Wed Oct 11, 2006 11:57 pm
Forum: PHP - Code
Topic: Sorting an array alphabetically, human-style
Replies: 5
Views: 695

Sorting an array alphabetically, human-style

I have some code that pulls records from a mySQL database and displays them in alphabetical order. This works just fine as far as a computer is concerned, but to a human the results look out of whack. For example, take these four arbitrary phrases: Lois Lane Superman Robots Superman, Man of Steel Th...
by CobraCards
Wed Feb 08, 2006 1:56 pm
Forum: Regex
Topic: Ignoring spaces and punctuation
Replies: 2
Views: 2191

Ignoring spaces and punctuation

I'm looking for a way to have my regex account for variations in spacing/punctuation. For example, if I'm looking for "gradepoint", I would want "gradepoint", "grade point", "grade-point", "gr.ade-po!i?nt." etc. all to match. (Please note that this i...
by CobraCards
Wed Feb 08, 2006 1:35 pm
Forum: Regex
Topic: Case-insensitive, lookaround, variable replacement!
Replies: 6
Views: 2941

Cool, thanks... I wasn't able to plug that in directly, but looking at your regex led me to the answer I needed. :)

I ran into one more hurdle, will start a new thread for it though.
by CobraCards
Tue Feb 07, 2006 10:55 pm
Forum: Regex
Topic: Case-insensitive, lookaround, variable replacement!
Replies: 6
Views: 2941

To give the background, this code will be used to search messages posted to my trading card game forums, and turn all card titles (a few thousand possibilities, the full list is pulled from a database) into links to that card's image and text. In the code I'm currently using, the line that does the ...
by CobraCards
Tue Feb 07, 2006 9:49 pm
Forum: Regex
Topic: Case-insensitive, lookaround, variable replacement!
Replies: 6
Views: 2941

Case-insensitive, lookaround, variable replacement!

I need to look take a long text string and replace certain smaller strings within it. Specific requirements: 1) The strings to match need to be passed as variables. 2) Matches should look ahead (and behind) to non-alphabetical characters. (The point being to prevent matches within a word -- e.g., I ...
by CobraCards
Tue Feb 07, 2006 6:53 pm
Forum: PHP - Code
Topic: Manipulating arrays and mySQL query results
Replies: 2
Views: 329

Manipulating arrays and mySQL query results

I need to fetch the contents (text stings) of a mySQL database table, stripping the tags from each text string, and putting them in order of descending length. For example, if my database contains: XXXXX <b>YYYY</b> ZZZZZZZZZ Then I would get this array: ZZZZZZZZZ XXXXX YYYY The code I'm using now i...
by CobraCards
Sun Feb 05, 2006 12:23 pm
Forum: PHP - Code
Topic: Turning certain phrases in a block of text into links!
Replies: 12
Views: 865

Oops, have been sitting on this page for a while, didn't see wtf's last post. That will work in some cases, but not in all. Even if "Karplusan Forest" is changed to "Karplusan%20Forest", it will still match "Forest" as well. (Likewise, "Legolas%20Fearless%20Marksma...
by CobraCards
Sun Feb 05, 2006 12:19 pm
Forum: PHP - Code
Topic: Turning certain phrases in a block of text into links!
Replies: 12
Views: 865

Jcart | Please use and tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color] All right, here's the code I'm using now: $links_cardlist = mysql_query(" SELECT products_name, products_id FROM products_desc...
by CobraCards
Sat Feb 04, 2006 10:48 pm
Forum: PHP - Code
Topic: Turning certain phrases in a block of text into links!
Replies: 12
Views: 865

I think I might actually go back to the idea of doing the replacement when the article is submitted. Having a few older articles that aren't properly linked (or having to resubmit them) seems the least of the available evils. :lol: Will definitely have to store the raw text somewhere when I make tha...
by CobraCards
Sat Feb 04, 2006 9:44 pm
Forum: PHP - Code
Topic: Turning certain phrases in a block of text into links!
Replies: 12
Views: 865

I think I'd prefer to keep this an automatic thing, and to have it happen immediately so that people see the linked version right after it's posted -- but I will definitely keep those other ideas in mind, thanks! I now have the DB query sorting cardnames by length, but that doesn't completely solve ...
by CobraCards
Sat Feb 04, 2006 6:22 pm
Forum: PHP - Code
Topic: Turning certain phrases in a block of text into links!
Replies: 12
Views: 865

Sorry if I'm being dense, but... how does that relate to my problem? 8)
by CobraCards
Fri Feb 03, 2006 5:17 pm
Forum: PHP - Code
Topic: Turning certain phrases in a block of text into links!
Replies: 12
Views: 865

Good idea, although in my particular case that would also create maintenance issues. I've got the parse time down to 1 second, which seems reasonable. Still struggling with the overlapping name problem though. The simplest fix I can think of is to check names from longest to shortest, and to check o...
by CobraCards
Fri Feb 03, 2006 1:57 pm
Forum: PHP - Code
Topic: Turning certain phrases in a block of text into links!
Replies: 12
Views: 865

Turning certain phrases in a block of text into links!

I run a website selling trading card games (Magic: The Gathering, Lord of the Rings TCG, etc.), and recently added a strategy section to the site where people can post their deck ideas and such. I would like to set my strategy section up so that all card names display as links to the detail page for...