Meet Swift Regex

RSS for tag

Discuss the WWDC22 Session Meet Swift Regex

Posts under wwdc2022-110357 tag

6 Posts
Sort by:
Post not yet marked as solved
0 Replies
60 Views
Code to reproduce: let inputString = "url(https://example.com)" let regex = Regex {   "url("   Capture {     .url()   }   ")" } guard let (_, url) = inputString.firstMatch(of: regex)?.output else {   fatalError() } print(url) Regex matches if we change "url(" to "(": let regex = Regex {   "("   Capture {     .url()   }   ")" } However, the output is Is this a bug?
Posted
by auriaiur.
Last updated
.
Post not yet marked as solved
0 Replies
123 Views
Feedback is filed. Trying to look into the Core.swift. diagnostics: Unsupported: 'Consumer for unconverted(_StringProcessing.DSLTree._AST.Atom(ast:  ---------------------------------------- CrashReportError: Fatal Error in Core.swift UtilityScript crashed due to fatalError in Core.swift at line 77. 'try!' expression unexpectedly raised an error: Unsupported: 'Consumer for unconverted(_StringProcessing.DSLTree._AST.Atom(ast:  ))' Process: UtilityScript[3141] Date/Time: 2022-07-02 03:56:17 +0000 Log File: <none> Application Specific Information:     dyld [         dyld config: DYLD_LIBRARY_PATH=/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/UtilityScript-frovasvohxblobefzbrrwtvqtyuu/Build/Intermediates.noindex/Previews/UtilityScript/Products/Debug DYLD_FRAMEWORK_PATH=/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/UtilityScript-frovasvohxblobefzbrrwtvqtyuu/Build/Intermediates.noindex/Previews/UtilityScript/Products/Debug     ]     libswiftCore.dylib [         _StringProcessing/Core.swift:77: Fatal error: 'try!' expression unexpectedly raised an error: Unsupported: 'Consumer for unconverted(_StringProcessing.DSLTree._AST.Atom(ast:  ))'         /AppleInternal/Library/BuildRoots/0cc5e7ad-e86f-11ec-ac50-3e2aa58faa6a/Library/Caches/com.apple.xbs/Sources/swiftlang_overlay_Platform/swift-experimental-string-processing/Sources/_StringProcessing/ConsumerInterface.swift:200     ]
Posted Last updated
.
Post not yet marked as solved
1 Replies
197 Views
If I past the samele code import RegexBuilder let fieldSeparator = /\s{2,}|\t/ let transactionMatcher = Regex { /CREDIT|DEBIT/ fieldSeparator One(.date(.numeric, locale: Locale(identifier: "en_US"), timeZone: .gmt)) fieldSeparator OneOrMore { NegativeLookahead { fieldSeparator } CharacterClass.any } fieldSeparator One(.localizedCurrency(code: "USD").locale(Locale(identifier: "en_US"))) } It does not like the OneOrMore with the negative look ahead. Is there an updated example of this code from WWDC?
Posted Last updated
.
Post not yet marked as solved
2 Replies
264 Views
Using Version 14.0 beta (14A5228q) on Monterey 12.4 I am trying to follow the 'Meet Swift regex' presentation dated 7 June but I have stumbled on the most basic of errors that I cannot get around. At 3:56 in the video, the following line of code is shown let transaction = "DEBIT 03/05/2022 Doug's Dugout Dogs $33.27" let fragments = transaction.split(separator: /\s{2,}|\t/) // ["DEBIT", "03/05/2022", "Doug's Dugout Dogs", "$33.27"]`` The '/' of the separator string generates the error: error: cannot convert value of type 'Regex' to expected argument type 'String.Element' (aka 'Character') I am embarrassed but also stuck on the simple issue and I cannot figure out what I am missing. TIA Chris
Posted
by CSantavy.
Last updated
.