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
Have you seen the new features that will be available in the upcoming C# 9 release?
C# is taking a lot of input from functional l...
New
I am a Linux user since 2012, more or less, and I always use Ubuntu on my computers, and my last 2 laptops have been used Thinkpads, wher...
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
Do you think it’s worth worrying about?
Do you think it’s going to be an even bigger issue in future?
If so what can the teams of smaller...
New
What do people think about Data-Oriented Programming, like this book tackles? https://www.manning.com/books/data-oriented-programming
Ho...
New
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New
Maybe a specific language or framework? Or a book or tool perhaps? What’s made your life easier and what do you think could make the live...
New
Kubernetes is everywhere. Transactional apps, video streaming services and machine learning workloads are finding a home on this ever-gro...
New
00:00 The Year 2022
00:38 Web3
03:28 Metaverse
05:05 AI
06:22 Databases
07:31 JavaScript
09:58 Other Trends to Know
WDYT - what wi...
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
Reading something? Working on something? Planning something? Changing jobs even!?
If you’re up for sharing, please let us know what you’...
New
We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
New
New
Author Spotlight
Mike Riley
@mriley
This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
There appears to have been an update that has changed the terminology for what has previously been known as the Taskbar Overflow - this h...
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
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
Fight complexity and reclaim the original spirit of agility by learning to simplify how you develop software. The result: a more humane a...
New
A concise guide to MySQL 9 database administration, covering fundamental concepts, techniques, and best practices.
Neil Smyth
MySQL...
New
Background
Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
New
Categories:
Sub Categories:
- All
- In The News (10441)
- Dev Chat
- Questions (34)
- Resources (119)
- Blogs/Talks (27)
- Jobs (3)
- Events (15)
- Code Editors (59)
- Hardware (57)
- Reviews (5)
- Sales (16)
- Design & UX (5)
- Marketing & SEO (2)
- Industry & Culture (14)
- Ethics & Privacy (19)
- Business (4)
- Learning Methods (5)
- Content Creators (7)
- DevOps & Hosting (9)
Popular Portals
- /elixir
- /rust
- /ruby
- /wasm
- /erlang
- /phoenix
- /keyboards
- /python
- /js
- /rails
- /security
- /go
- /swift
- /vim
- /clojure
- /emacs
- /haskell
- /java
- /svelte
- /onivim
- /typescript
- /kotlin
- /c-plus-plus
- /crystal
- /tailwind
- /react
- /gleam
- /ocaml
- /flutter
- /elm
- /vscode
- /ash
- /html
- /opensuse
- /centos
- /php
- /deepseek
- /zig
- /scala
- /sublime-text
- /lisp
- /textmate
- /react-native
- /nixos
- /debian
- /agda
- /kubuntu
- /arch-linux
- /deno
- /django
- /ubuntu
- /revery
- /spring
- /nodejs
- /manjaro
- /diversity
- /lua
- /julia
- /slackware
- /c







