KimberlyBrooke
Elixir Exercism Acronym
I am working to understand xianrusso’s solution to Exercism’s Acronym solution.
defmodule Acronym do
def abbreviate(string) do
Regex.scan(~r/(?<![A-Z])[A-Z]|(?<!\')\b[a-z]/, string)
|> List.flatten
|> Enum.map(&String.upcase/1)
|> Enum.join
end
end
The portion that I am working to digest is the Regex.
I believe this link contains the answer I just want to confirm that what I am thinking is happening is indeed what is happening. Advanced Regex Tutorial—Regex Syntax
I believe that in this ~r/(?<![A-Z])[A-Z]/ - that the (?<![A-Z]) is saying that as long as where we are at in the string does not have a capital letter that immediately precedes it then we can continue to keep matching it to [A-Z].
I believe that in this ~r/(?<!')\b[a-z]/ it is saying that as long as where we are at in the string there is not a ' that precedes it then we can keep matching it to \b[a-z]
Trending in Challenges
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
eksperimental
quiet, but note that
\bis s zero-width (same as lookbehinds) assertion, which is a word boundary. A limit between \w (a word) and a non-word (\W), or the beginning or end of a word.So the second part of the regex is telling you [a-z] preceeded by any non-word that is not a single quote, and it can match a [a-z] at the beginning of the string.
eksperimental
The regex commented out in plain English:
Note the regex is valid, feel free to use it in your code, if you want.
KimberlyBrooke
Thank you!
eksperimental
No worries