Post Reply 
 
Freshness Rating:
  • 2 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Gossamer's Regex Quirkshop
Offline 11-15-2016, 11:56 AM
Reply: #11
RE: Gossamer's Regex Quirkshop
(11-14-2016 08:51 PM)AncientE%cursion Wrote:  Alright, I've got something expanding on that idea. Basically, when I type out a message and the words have 'a's and 'b's in a series like 'about' or 'babadook', the brackets make it awfully spacious. Do you reckon there's a way to make every series of those letters 'a' and 'b' be collected in one set of brackets?

So instead of this: [A][B]out; [8][A][8][A]dook, it's [A8]out; [8A8A]dook.

Totally! Here's my solution:
Code:
Simple Replacements:
a to A

Regex Replacements:
([AbB]+) to [$1]
[bB] to 8

As a special note, the reason I have the b to 8 replacement in the regex part is because, if we put it in the simple replacement section, it would happen before we add brackets, and we'd end up putting brackets around any 8's as well! This way, we only put the b's in brackets.
Find all replies by this user
Quote this message in a reply
Offline 11-15-2016, 06:26 PM
Reply: #12
RE: Gossamer's Regex Quirkshop
Works perfectly. Cheers a bunch.

[Image: 9bb7pc.gif]

Do the evolution
Find all replies by this user
Quote this message in a reply
Offline 11-16-2016, 04:09 PM
Reply: #13
RE: Gossamer's Regex Quirkshop
Can I ask your help on a quirk for a friend's fantroll? The quirk is simple: the first word has its first letter capitalized, the second word gets its last letter capitalized, the third has the first letter capitalized again and so on. "Kinda likE This, foR Example." And hopefully it won't interfere with the ability to fully capitalize the words, just in case.

My fan adventures:

Troll Jailbreak

Trolls but no SGRUB

A kid in some strange world
Find all replies by this user
Quote this message in a reply
Offline 11-16-2016, 07:10 PM (This reply was last modified: 11-16-2016 07:29 PM by gossamerGadgeteer.)(Edited by gossamerGadgeteer.)
Reply: #14
RE: Gossamer's Regex Quirkshop
(11-16-2016 04:09 PM)Fubar Wrote:  Can I ask your help on a quirk for a friend's fantroll? The quirk is simple: the first word has its first letter capitalized, the second word gets its last letter capitalized, the third has the first letter capitalized again and so on. "Kinda likE This, foR Example." And hopefully it won't interfere with the ability to fully capitalize the words, just in case.

EDIT: Whoops! I re-read your request, and I may have been overthinking it. If, instead of the pattern of upper-to-upper and lower-to-lower, you really just want every odd-numbered word to start with a capital and every even-numbered word to end with a capital, you can use this:

Code:
Case: lower case

Regex Replacements:
([\w']+(?:[^\w']+[\w']+)?) to ±$1±
(±[\w']+)± to $1
(±[\w']|[\w']±) to $U
± to

If you want the pattern, however, see below for my original attempt:

Let me know how it works for you, and feel free to ask for any tweaks you need!
Find all replies by this user
Quote this message in a reply
Offline 11-17-2016, 02:04 AM
Reply: #15
RE: Gossamer's Regex Quirkshop
If you're still doing this I was wondering if you could help me? One of my trolls has a quirk where they CapiTalize EverY oTher sylLable. And if that's too hard, which I realize it probably is whoops. I was thinking of streamlining it down to capitalizeing every other word So something Like this? Thank you!

main children:Hal, Dave, Dirk, alt!Calliope
also will do:Caliborn, Calliope, Aradia, Roxy, Damara, Latula

[Image: tumblr_mfrp5pt6yC1ql2frko1_400.gif]
#is a dirty robo hecker
Find all replies by this user
Quote this message in a reply
Offline 11-18-2016, 09:07 AM
Reply: #16
RE: Gossamer's Regex Quirkshop
(11-17-2016 02:04 AM)conscienceVoid Wrote:  If you're still doing this I was wondering if you could help me? One of my trolls has a quirk where they CapiTalize EverY oTher sylLable. And if that's too hard, which I realize it probably is whoops. I was thinking of streamlining it down to capitalizeing every other word So something Like this? Thank you!

There's no definitive algorithm for determining the location of syllables in a word, so automating something like that would require access to a dictionary, which is something regex doesn't have. If you really wanted to automate this, you'd have to add each word with more than 1 syllable manually as a replacement, with syllable markers. (e.g., treaty to trea*ty, capitalize to cap*i*tal*ize, etc.) At that point, you'd be able to do the alternating caps with regex, but that's A Lot™ of work! If you do want to do that, let me know, and I can do the alternating caps part lol.

As for capitalizing every other word, that one's totally doable!

Code:
Case: lower case

Regex Replacements:
([\w'-]+([^\w'-]+[\w'-]+)?) to ±$1
±.*?\w to $U
± to

This also handles apostrophes and hyphens used in words, and is compatible with numbers in/as words as well. And if a word that should be capitalized starts with an apostrophe or hyphen for any reason, it'll capitalize the first letter.

As always, let me know if you have any feedback or questions!
Find all replies by this user
Quote this message in a reply
Offline 11-18-2016, 09:29 AM
Reply: #17
RE: Gossamer's Regex Quirkshop
What's the most complex regex you've ever made, worked on?

[Image: 9bb7pc.gif]

Do the evolution
Find all replies by this user
Quote this message in a reply
Offline 11-18-2016, 10:12 AM
Reply: #18
RE: Gossamer's Regex Quirkshop
(11-18-2016 09:29 AM)AncientE%cursion Wrote:  What's the most complex regex you've ever made, worked on?

In terms of quirks, probably the one listed as "advanced level" in my original post! That one was a doozy to figure out.

I've done other regex that involved the nonsense that is lookaheads and lookbehinds and using captured group references in the search string itself, but that was all for boring work stuff haha.
Find all replies by this user
Quote this message in a reply
Offline 11-25-2016, 02:29 PM
Reply: #19
RE: Gossamer's Regex Quirkshop
Hey, what would the regex for capitalizing the last letter of every word look like? I have a character who, on account of not really knowing regex, I've had to emulate that quirk by having every possible letter/space and letter/punctuation (ALL the punctuation, at that) combination as a simple replacement, and it's a pain to turn off my quirk because of it.
Find all replies by this user
Quote this message in a reply
Offline 11-25-2016, 06:52 PM
Reply: #20
RE: Gossamer's Regex Quirkshop
(11-25-2016 02:29 PM)Milomus2 Wrote:  Hey, what would the regex for capitalizing the last letter of every word look like? I have a character who, on account of not really knowing regex, I've had to emulate that quirk by having every possible letter/space and letter/punctuation (ALL the punctuation, at that) combination as a simple replacement, and it's a pain to turn off my quirk because of it.

Situations like this are exactly why I made this thread! Big Grin Here's your quirk!

Code:
Regex Replacements:
\w['-]($|\W) to $U
\w($|[^\w'-]) to $U

That'll handle every possible letter/space and letter/punctuation combination, and also work at the end of a line with no punctuation, and on words with apostrophes or hyphens.

Let me know if you have any feedback or questions!
Find all replies by this user
Quote this message in a reply
Post Reply 


Board jump:


User(s) browsing this memo: 1 Guest(s)