
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.
First Post!

AstonJ
Interesting! Wonder if something similar could be done for other languages?
I’d be lost without rubular.com
Popular General Dev topics

Inspired by this thread about arcade games - which I initially misread as favorite arcade game soundtracks - I wanted to ask about your f...
New

Inspired by this tweet by @dasdom
Even if you take out all the damage being done by humans, our planet has about 50B years before bein...
New

TL;DR: words that incorporate negation are acceptable, eg. independent, asymmetric, nondeterministic.
An example in the book is to renam...
New

@rvirding
@OvermindDL1
New

The dev world doesn’t sit still, in fact it is probably one of the fastest paced industries around - meaning to stay current we are conti...
New

For those that are interested, Snyk (developer security tool) announced support for Elixir earlier this week:
Just thought I’d pass it...
New

Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
New

A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New

I’ve been watching Prag Dave’s Elixir course and I noticed he uses tree:
Tree is a recursive directory listing program that produces a ...
New

Chris Seaton, the creator of TruffleRuby has died. It appears from suicide :cry:
He left this note on Twitter on the weekend:
And one...
New
Other popular topics

New

Do the test and post your score :nerd_face:
:keyboard:
If possible, please add info such as the keyboard you’re using, the layout (Qw...
New

Hello content creators! Happy new year. What tech topics do you think will be the focus of 2021? My vote for one topic is ethics in tech...
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

Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New

If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol:
bre...
New

Author Spotlight
Mike Riley
@mriley
This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New

zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig.
General-purpose programming language and toolchain for maintaini...
New

A Brief Review of the Minisforum V3 AMD Tablet.
Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
New

Hello,
I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
New
Categories:
Sub Categories:
- All
- In The News (10039)
- Dev Chat
- Questions (32)
- Resources (118)
- Blogs/Talks (26)
- Jobs (3)
- Events (15)
- Code Editors (58)
- Hardware (57)
- Reviews (4)
- Sales (15)
- Design & UX (4)
- Marketing & SEO (1)
- Industry & Culture (14)
- Ethics & Privacy (19)
- Business (4)
- Learning Methods (4)
- Content Creators (7)
- DevOps & Hosting (9)
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /emacs
- /haskell
- /onivim
- /svelte
- /typescript
- /crystal
- /c-plus-plus
- /kotlin
- /tailwind
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /ash
- /opensuse
- /centos
- /php
- /deepseek
- /html
- /scala
- /zig
- /debian
- /textmate
- /sublime-text
- /nixos
- /lisp
- /agda
- /react-native
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /spring
- /django
- /manjaro
- /diversity
- /nodejs
- /lua
- /slackware
- /c
- /julia
- /markdown