Christian Selig on Nostr: Dumb Swift question: with the new built-in regex stuff, how do I just get a match as ...
Dumb Swift question: with the new built-in regex stuff, how do I just get a match as a string?
let input = "A cat walked"
let regex = /[a-z]{3}/
let match = input.firstMatch(of: regex)
I want "cat" as a string, but the result is of type Regex<Regex<Substring>.RegexOutput>.Match?
What do I do?
Published at
2023-09-09 21:19:28Event JSON
{
"id": "b1c166ec294526180b2b83d6bd1a1b240a3e980dcb942b773f99200a1fe981e5",
"pubkey": "de6adda4d139627ce8f9cf05ef27c7cd1de9895363e5f303667f761bec318716",
"created_at": 1694294368,
"kind": 1,
"tags": [
[
"proxy",
"https://mastodon.social/users/christianselig/statuses/111037275766707422",
"activitypub"
]
],
"content": "Dumb Swift question: with the new built-in regex stuff, how do I just get a match as a string?\n\nlet input = \"A cat walked\"\nlet regex = /[a-z]{3}/\nlet match = input.firstMatch(of: regex)\n\nI want \"cat\" as a string, but the result is of type Regex\u003cRegex\u003cSubstring\u003e.RegexOutput\u003e.Match?\n\nWhat do I do?",
"sig": "41ab0fe4b629ac8a6e82627879872d6023cca80840e639cacb0b56ac25ba5137393dcc9683c8fafc38429b7871d7a9ea74ce65d5486f4ed5d761c05896046f00"
}