
Maartz
New Swift's Regex DSL
Hey,
I love Regex, letting my kids slaming the keyboard until finding the good regex to do the job has always been a source of joy and pleasure.
But it seems that this time is over… at least for the Swift folks around here.
This DSL allows to create a Regex with in a “a la” SwiftUI approach.
import RegexBuilder
let emailPattern = Regex {
let word = OneOrMore(.word)
Capture {
ZeroOrMore {
word
"."
}
word
}
"@"
Capture {
word
OneOrMore {
"."
word
}
}
} // => Regex<(Substring, Substring, Substring)>
let email = "My email is my.name@mail.swift.org."
if let match = try emailPattern.firstMatch(in: email) {
let (wholeMatch, name, domain) = match.output
// wholeMatch: "my.name@mail.swift.org"
// name: "my.name"
// domain: "mail.swift.org"
}
The first exemple is absolutely terrific and I’ve watched the whole video. It’s promising.
What do you think of this new approach?
I’d be very happy to see it adopted in other languages. IMHO it’s time to drop the old syntax.
Popular General Dev topics

The obligatory speed test thread :smiley:
Check here: https://www.speedtest.net
When complete, click on the share link and copy and pas...
New

Figured this would be a cool topic and maybe provide some inspiration for those who are just starting to work from home. Feel free to sha...
New

Thanks to @AstonJ for encouraging me to post this here:
An introduction to alternative keyboard layouts
Feel free to post your own expe...
New

Tell us what kind of machine/hardware do you have? and what kind of reason for?
describe your hardware… :computer: :nerd_face:
New

SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New

Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
New

Think Again 50% Off Sale »
The theme of this sale is new perspectives on familiar topics.
Enter coupon code ThinkAgain2021 at checkout t...
New

Saw this on TikTok of all places! :lol:
Anyone heard of them before?
Lite:
New

Big O Notation can make your code faster by orders of magnitude. Get the hands-on info you need to master data structures and algorithms ...
New
Other popular topics

What chair do you have while working… and why?
Is there a ‘best’ type of chair or working position for developers?
New

You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New

Here’s our thread for the Keyboardio Atreus. It is a mechanical keyboard based on and a slight update of the original Atreus (Keyboardio ...
New

Not sure if following fits exactly this thread, or if we should have a hobby thread…
For many years I’m designing and building model air...
New

Woooooooo! This is such a huge release for it, and 2 years incoming!
In short, the library is now using an updated hyper backend (not j...
New

If you want a quick and easy way to block any website on your Mac using Little Snitch simply…
File > New Rule:
And select Deny, O...
New

Author Spotlight:
Bruce Tate
@redrapids
Programming languages always emerge out of need, and if that’s not always true, they’re defin...
New

Will Swifties’ war on AI fakes spark a deepfake porn reckoning?
New

This is cool!
DEEPSEEK-V3 ON M4 MAC: BLAZING FAST INFERENCE ON APPLE SILICON
We just witnessed something incredible: the largest open-s...
New

This is a very quick guide, you just need to:
Download LM Studio: https://lmstudio.ai/
Click on search
Type DeepSeek, then select the o...
New
Latest in General Dev
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /centos
- /ash
- /php
- /deepseek
- /scala
- /zig
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /spring
- /django
- /diversity
- /lua
- /nodejs
- /c
- /julia
- /slackware
- /neovim