Regular Expressions 101

Save & Share

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8
  • .NET 7.0 (C#)
  • Rust
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests

Tools

Sponsors
There are currently no sponsors. Become a sponsor today!
An explanation of your regex will be automatically generated as you type.
Detailed match information will be displayed here automatically.
  • All Tokens
  • Common Tokens
  • General Tokens
  • Anchors
  • Meta Sequences
  • Quantifiers
  • Group Constructs
  • Character Classes
  • Flags/Modifiers
  • Substitution
  • A single character of: a, b or c
    [abc]
  • A character except: a, b or c
    [^abc]
  • A character in the range: a-z
    [a-z]
  • A character not in the range: a-z
    [^a-z]
  • A character in the range: a-z or A-Z
    [a-zA-Z]
  • Any single character
    .
  • Alternate - match either a or b
    a|b
  • Any whitespace character
    \s
  • Any non-whitespace character
    \S
  • Any digit
    \d
  • Any non-digit
    \D
  • Any word character
    \w
  • Any non-word character
    \W
  • Non-capturing group
    (?:...)
  • Capturing group
    (...)
  • Zero or one of a
    a?
  • Zero or more of a
    a*
  • One or more of a
    a+
  • Exactly 3 of a
    a{3}
  • 3 or more of a
    a{3,}
  • Between 3 and 6 of a
    a{3,6}
  • Start of string
    ^
  • End of string
    $
  • A word boundary
    \b
  • Non-word boundary
    \B

Regular Expression

/
/
gmi

Test String

Code Generator

Generated Code

import Foundation let pattern = #"(?<=pts\. ;)(.*)(?= ;\D)|;(?<=Overall Score ;).*(?= ;)"# let regex = try! NSRegularExpression(pattern: pattern, options: [.anchorsMatchLines, .caseInsensitive]) let testString = #""" 1 "Simulator is not connected to SimNowlLink ;teports ;'ERFORMANCE REPORT ;USER: ;EXERCISE: ;ATTEMPT, ;NOTES: ;IDemoUser ;Ring Rollercoaster 1 ;SCORE: ;26 ;88 ;DATE: 09/04/2020 08:20:36 ;Pay attention to all penalties. You ;can improve drops by following this ;advice: ;• handle grasped objects ;carefully, use the wristed ;instruments to properly position ;object in the grasper. ;camera clutch to optimize your ;field of view. ;LAUNCH EXERCISE ;SURGICAL' ;SCORE BREAKDOWN: ;Efficiency Metrics ;Economy of ;Time to Complete ;Raw Value ;178.0 cm ;129.1 sec. ;50.0 ;50.0 ;Efficiency Subtotat ;Penalties ;Ring Collision Warning (Yellow) ;Ring Excessive Force (Red) ;Instrument-Instrument Collisions ;Instrument-Endoscope Collisions ;Endoscope-Environment Collisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Vatue ;13.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 sec. ;2.0 ct. ;1.0 ct. ;Penalty Subtotal ;Overall Score ;pts. ;65.3 ;28.9 ;94 ;-1.3 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-4.0 ;-0.3 ;-6 ;88 ;k. ; 2 "Simulator is not connected to SimNowlLink ;Reports ;PERFORMANCE REPORT ;IPtmoUser ;USE R?' ;Ring Rollercoaster 1 ;EXERCISE: ;ATT ÉivlPT ;27 ;DATE: 09/04/2020 ;SCORE BREAKDOWN', ;NOTES: ;Really focus on improving drops by ;following these ;0' handle grasped objectS ;carefully, use the wristed ;instruments to properly position ;object in the grasper. ;•j camera clutch to optimize your ;field of view. ;NCH €XERCISE ;INTUITIVE ;SURGICAL v ;SCORE: ;Raw Value ;177.7 cm ;143.4 sec. ;Efficiency hetrics ;Economy bf Åotion ;Time to Complete ;Penalties ;Efficiency Subtotal ;Ring Collision Warning (Yéllow) ;Ring Excessive Force (Red) ;Instrument-Instrument Collisions ;instrument•Endoscope Collisions ;'Endoscope-Environment Collisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Value ;14.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.4 sec. ;3.0 ct. ;0.0 ct. ;Max Pts. ;50.0 65.4 ;50.0 23.8 ;89 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-6.0 ;-0.0 ;Penalty Subtotal ;Overall Score ; 3 "Simulator is not connected to SimNowlLink ;Reports ;PERFORMANCE REPORT ;USER: ;EXERCISE: ;ATTEMPT ;NOTES: ;DemoUser ;Ring Rollercoaster 1 ;28 ;DATE: 09/04/2020 ;SCORE: ;95 ;Good job improving drops! Continue ;to follow this advice to score even ;better: ;SCORE BREAKDOWN: ;Efficiency Metrics ;Economy of Motion ;Time to Complete ;Efficiency Subtotal ;Penalties ;Ring Cottision Warning (Yellow) ;Ring Excessive Force (Red) ;Instrument.lnstrument Collisions ;Instrument -Endoscope Collisions ;Endoscope-Environment Collisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Value ;149.5 cm ;101.5 sec. ;Raw Value ;8.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 sec. ;2.0 ct. ;1.0 ct. ;50.0 ;50.0 ;• ;• ;handle grasped objects ;carefully, use the wristed ;instruments to properly position ;object in the grasper. ;camera clutch to optimize your ;field of view. ;LAUNCH EXERCISE ;INTUITIVE ;SURGICAL' ;Penalty Subtotal ;Overall Score ;pts. ;70.1 ;38.7 ;too ;-0.8 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-4.0 ;.0.3 ;-5 ;95 ; 4 "Simulator is not connected to SimNowlLink ;Reports ;PERFORMANCE REPORT ;USER: ;EXERCISE: ;ATTEMPT: ;NOTES: ;DemoUser ;Ring Rollercoaster 1 ;29 ;DATE: 09/04/2020 ;SCORE BREAKDOWN: ;Efficiency Metrics ;Economy of Motioh ;Time to Complete ;SCORE: ;Raw Value ;170.8 cm ;138.3 sec. ;Really focus on improving drops by ;following these techniques: ;• handle grasped objects ;carefully, use the wristed ;instruments to properly position ;object in the grasper. ;• camera clutch to optimize your ;field of view. ;LAUNCH EXERCISE ;INTUITIVE ;SURGICAL r ;Efficiency Subtotat ;Penalties ;Raw Value ;Ring Collision Warning (Yellow) ;, 14.0 ct. ;0.0 ci. ;Ring Excessive Force (Red) ;Instrument-Instrument Collisions ;0.0 ct. ;Instrument-Endoscope CollisionS ;0.0 ct. ;Endoscope-Environment Collisions ;0.0 ct. ;Excessive Force ;0.0 sec. ;Drops ;5.0 ct. ;Instruments Out of View ;0.0 ct. ;Penalty Subtotal ;Overall Score ;Pts. ;50.0 66.5 ;50.0 25.6 ;92 ;-1.4 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-10.0 ;-0.0 ;-11 ;81 ; 5 "Simulator is not connected to SimNowlLink ;Reports ;PERFORMANCE REPORT ;USER: ;EXERCISE: ;ATTEMPt ;NOTES: ;DemoUser ;Ring Rollercoaster 1 ;31 ;DATE: 09/04/2020 08:33:34 ;SCORE BREAKDOWN: ;SCORE: ;85 ;Good job improving drops! , Continue ;to follow this advice to score, even ;better:, ;• handle grasped objects ;carefully, use the wristed ;instruments to properly position ;object in the grasper. ;• camera clutch to optimize your ;field of view. ;LAUNCH EXERCISE ;INTUITIVE ;SURGICAL r ;Efficiency Metrics ;Economy of Motion ;Time to Complete ;Raw Value ;164.8 cm ;136.6 sec. ;Efficiency Subtotal. ;Penalties ;Ring Collision Warning (Yellow) ;Ring Excessive Force (Red) ;Instrument-instrument Collisions ;Instrument-Endoscope Collisions ;Endoscope-Environment Cottisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Value ;7.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 sec. ;4.0 ct. ;1.0 ct. ;Penalty Subtotal ;Overall Score ;Pts. ;50.0 67.5 ;50.0 26.2 ;-0.7 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-8.0 ;-0.3 ;85 ; 1 "imulator is not connected to SimNowlLink ;*ports ;RFORMANCE REPORT ;USER. ;EXERCISE ;ATTEMPT ;NOTES: ;DemoUser ;Sea Spikes 1 ;24 ;DATE. 09/02/2020 0812.46 ;SCORE BREAKDOWN: ;Great job improving your penalty ;score! Now try to improve cone ;collisions by doing the following: ;• carefully orient your wrists to ;avoid other cones when placing ;a ring on its target cone. ;be careful when placing a ring ;onto a cone. ;LAUNCH EXERCISE ;INTUITIVE ;SURGICAL' ;Efficiency Metrics ;Economy of Motion ;Time to Complete ;SCORE. ;Raw Value ;379.2 cm ;153.3 sec. ;Efficiency Subtotal ;penalties ;Instrument-instrument Collisions ;Incorrect Rings ;Cone Collisions ;Instrument-Endoscope Collisions ;Endoscope-Environment Collisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Value ;0.0 ct. ;0.0 ct. ;7.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 sec. ;0.0 ct. ;0.0 ct. ;Penalty Subtotal ;Overall Score ;Max Pts. ;50.0 42.1 ;50.0 34.4 ;pts. ;-0.0 ;-0.0 ;-14.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-14 ;63 ; 2 "imulator is not connected to SimNowlLink ;*ports ;RFORMANCE REPORT ;USER ;EXERCISE ;ATTEMPT ;NOTES: ;DemoUser ;Sea Spikes 1 ;26 ;DATE. 09/02/2020 08 3200 ;SCORE BREAKDOWN: ;Efficiency Metrics ;Economy of Motion ;Time to Complete ;SCORE. ;Raw Value ;390.2 cm ;154.5 sec. ;Good job improving cone collisions! ;Continue to follow this advice to ;score even better: ;• carefully orient your wrists to ;avoid other cones when placing ;a ring on its target cone. ;be careful when placing a ring ;onto a cone. ;LAUNCH EXERCISE ;INT U t TIVE ;SURGICAL' ;Efficiency Subtotal ;Penalties ;Instrument-Instrument Collisions ;Incorrect Rings ;Cone Collisions ;Instrument-Endoscope Collisions ;Endoscope-Environment Collisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Value ;0.0 ct. ;0.0 ct. ;6.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 sec. ;0.0 ct. ;0.0 ct. ;Penalty Subtotal ;Overall Score ;Pts. ;50.0 41.0 ;50.0 34.3 ;75 ;pts. ;-0.0 ;-0.0 ;-12.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;.12 ;63 ; 3 "not connected to SimNowlLink ;INCE REPORT ;USER: ;EXERCISE: ;ATTEMPT: ;NOTES: ;DemoUser ;Sea Spikes 1 ;27 ;DATE: 09/02/2020 ;SCORE: ;65 ;Good job improving cone collisions! ;Continue to follow this advice to ;score even better: ;• carefully orient your wrists to ;avoid other cones when placing ;a ring on its target cone. ;• be careful when placing a ring ;onto a cone. ;LAUNCH EXERCISE ;INTUITIVE ;SURGICAL' ;SCORE BREAKDOWN: ;Efficiency Metrics ;Economy Of Motion ;Time to Complete ;Efficiency Subtotal ;Penalties ;Instrument-Instrument Collisions ;Incorrect Rings ;Cone Collisions ;Instrument-Endoscope Collisions ;Endoscope-Environment Collisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Value ;427.0 cm ;160.3 sec. ;Raw Value ;0.0 ct. ;0.0 ct. ;3.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 sec. ;0.0 ct. ;t .0 ct. ;50.0 ;50.0 ;Penalty Subtotal ;Overall Score ;pts. ;37.3 ;33.3 ;71 ;-0.0 ;-0.0 ;-6.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.3 ;-6 ;65 ; 4 "s not connected to SimNowlLink ;XNCE REPORT ;USER: ;EXERCISE: ;ATTEMPT. ;NOTES: ;DemoUser ;Sea Spikes 1 ;28 ;09/02/2020 ;SCORE BREAKDOWN: ;Efficiency Metrics ;Economy of Motion ;Time to Complete ;SCORE: ;Raw Value ;417.1 cm ;166.2 sec. ;Continue to minimize penalties but ;pay closer attention to time to ;complete. The following techniques ;can help you improve: ;• camera clutch to maintain ;optimal field of view. ;• optimize your movements and ;decisions without compromising ;the other skillsets. ;LAUNCH EXERCISE ;SURGICALC ;50.0 ;50.0 ;Efficiency Subtotal ;Penalties ;Instrument-instrument Collisions ;Incorrect Rings ;Cone Collisions ;Instrument-Endoscope Collisions ;Endoscope-Environment Collisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Value ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.1 sec. ;0.0 ct. ;0.0 ct. ;Penalty Subtotal ;Overall Score ;pts. ;38.3 ;32.3 ;71 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;71 ; 5 "USER: ;EXERCISE: ;ATTEMPT. ;NOTES: ;DemoUser ;Sea Spikes 1 ;29 ;DATE: ;SCORE: ;09/02/2020 ;67 ;RMANCE REPORT ;Pay attention to all penalties. You ;can improve cone collisions by ;following this advice: ;• carefully orient your wrists to ;avoid other cones when placing ;a ring on its target cone. ;• be careful when placing a ring ;onto a cone. ;LAUNCH EXERCISE ;INTUITIVE ;SURGICAL ;SCORE BREAKDOWN: ;Efficiency Metrics ;Economy of Motion ;Time to Complete ;Raw Value ;404.8 cm ;183.7 sec. ;50.0 ;50.0 ;Efficiency Subtotal ;Penalties ;Instrument-Instrument Collisions ;Incorrect Rings ;Cone Collisions ;Instrument-Endoscope Collisions ;Endoscope-Environment Collisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Value ;0.0 ct. ;0.0 ct. ;1.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 sec. ;0.0 ct. ;0.0 ct. ;Penalty Subtotal ;Overall Score ;Pts. ;39.5 ;29.4 ;69 ;-0.0 ;-0.0 ;-2.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;.2 ;67 ; 6 "connected to SimNowlLink ;jCE REPORT ;USER: ;EXERCISE: ;ATT E M p T: ;NOTES: ;DemoUser ;Sea Spikes 1 ;30 ;DATE: ;SCORE: ;09/02/2020 ;70 ;Remember to improve cone ;collisions by following these ;techniques: ;• carefully orient your wrists to ;avoid other cones when placing ;a ring on its target cone. ;be careful when placing a ring ;onto a cone. ;LAUNCH EXERCISE ;SURGICAL&quot; ;SCORE BREAKDOWN: ;Raw Value ;Efficiency Metrics ;395.6 cm ;Economy of motion ;168.1 sec. ;Time to Complete ;Efficiency Subtotal ;50.0 ;50.0 ;Penalties ;Instrument-Instrument Collisions ;Incorrect Rings ;Cone Collisions ;Instrument-Endoscope Collisions ;Endoscope-Environment Collisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Value ;0.0 ct. ;0.0 ct. ;1.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 sec. ;0.0 ct. ;0.0 ct. ;Penalty Subtotal ;Overall Score ;40.4 ;32.0 ;72 ;00 ;-0.0 ;-2.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-2 ;70 ; 7 "nor is not connected to SimNowlLink ;RMANCE REPORT ;USER: ;EXERCISE: ;ATTEMPT ;NOTES: ;DemoUser ;Sea Spikes I ;31 ;SCORE: ;69 ;09/02/2020 08:49:55 ;Remember to improve cone ;collisions by following these ;techniques: ;• carefully orient your wrists to ;avoid other cones when placing ;a ring on its target cone. ;be careful when placing a ring ;onto a cone. ;LAUNCH EXERCISE ;SURGICALC ;SCORE BREAKDOWN: ;Efficiency Metrics ;Economy of Motion ;Time to Complete ;penalties ;Raw Value ;396.0 cm ;173.9 sec. ;Efficiency Subtotal ;50.0 ;50.0 ;Instrument-instrument Collisions ;Incorrect Rings ;Cone Collisions ;Instrument-Endoscope Collisions ;Endoscope-Environment Collisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Value ;0.0 ct. ;0.0 ct. ;1.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 sec. ;0.0 ct. ;0.0 ct. ;Penalty Subtotal ;Overall Score ;pts. ;40.4 ;31.0 ;71 ;-0.0 ;-0.0 ;-2.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-2 ;69 ; 8 "or is not connected to SimNowlLink ;rts ;MANCE REPORT ;USER: ;EXERCISE: ;ATTEMPT. ;NOTES: ;DemoUser ;Sea Spikes 1 ;32 ;DATE: ;09/02/2020 08:56:01 ;SCORE BREAKDOWN: ;Efficiency Metrics ;Economy of Motion ;Time to Complete ;SCORE: ;Raw Vatue ;354.5 cm ;151.7 sec. ;Pay attention to all penalties. You ;can improve cone collisions by ;following this advice: ;• carefully orient your wrists to ;avoid other cones when placing ;a ring on its target cone. ;be careful when placing a ring ;onto a cone. ;LAUNCH EXERCISE ;50.0 ;50.0 ;Efficiency Subtotal ;Penalties ;Instrument-Instrument Collisions ;Incorrect Rings ;Cone Collisions ;Instrument-Endoscope Collisions ;Endoscope-Environment Collisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Value ;0.0 ct. ;0.0 ct. ;1.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 sec. ;0.0 ct. ;0.0 ct. ;Penalty Subtotal ;Overall Score ;44.5 ;34.7 ;79 ;-0.0 ;-0.0 ;-2.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-2 ;77 ; 9 "•s not connected to SimNowlLink ;ANCE REPORT ;USER: ;EXERCISE: ;ATTEMPr ;NOTES: ;DemoUser ;Sea Spikes 1 ;33 ;DATE: ;SCORE: ;09/02/2020 08:59:19 ;80 ;Try to avoid penalties, focus on the ;following to help you -improve: ;handle grasped objects ;carefully, use the wristed ;instruments to properly position ;object in the grasper. ;• camera clutch to optimize your ;field of view. ;IAUNCH EXERCISE ;SURGICAL r ;SCORE BREAKDOWN: ;Efficiency Metrics ;Economy of Motion ;Time to Complete ;Raw Value ;336.3 cm ;143.9 sec. ;50.0 ;50.0 ;Efficiency Subtotal ;Penalties ;Instrument-instrument Collisions ;Incorrect Rings ;Cone Collisions ;Instrument-Endoscope Collisions ;Endoscope-Environment Collisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Value ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 sec. ;1.0 ct. ;0.0 ct. ;Penalty Subtotal ;Overall Score ;pts. ;46.4 ;36.0 ;82 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-2.0 ;-0.0 ;.2 ;80 ; 10 "ected to SimNowlLink ;REPORT ;'i ;USER: ;EXERCISE: ;ATTEMPT: ;NOTES: ;DemoUser ;Sea Spikes 1 ;34 ;SCORE: ;80 ;09/02/2020 09:03:02 ;SCORE BREAKDOWN: ;Continue to minimize penalties but ;pay closer attention to time to ;complete. The following techniques ;can help you improve: ;• camera clutch to maintain ;optimal field of view. ;• optimize your movements and ;decisions without compromising ;the other skillsets. ;LAUNCH EXERCISE ;INT UT TIVE ;SURGICAÜ ;Efficiency Metrics ;Economy of Motion ;Time to Complete ;Raw Value ;340.5 cm ;155.0 sec. ;Max ;50.0 ;50.0 ;Efficiency Subtotal ;Penalties ;Instrument-instrument Collisions ;Incorrect Rings ;Cone Collisions ;Instrument-Endoscope Collisions ;Endoscope-Environment Collisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Value ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 sec. ;0.0 ct. ;0.0 ct. ;Penalty Subtotal ;Overall Score ;pts. ;46.0 ;34.2 ;80 ;pts. ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;.0 ;80 ; 11 "USER: ;EXERCISE: ;ATTEMPT. ;NOTES: ;DemoUser ;Sea Spikes 1 ;35 ;09/02/2020 09.06Ä4 ;SCORE BREAKDOWN: ;Efficiency Metrics ;Economy of Motion ;Time to Complete ;SCORE: ;Raw Value ;401.0 cm ;169.7 sec. ;Pay attention to all penalties. You ;can improve drops by following this ;advice: ;• handle grasped objects ;carefully, use the wristed ;instruments to properly position ;object in the grasper. ;• camera clutch to optimize your ;field of view. ;LAUNCH EXERCISE ;50.0 ;50.0 ;Efficiency Subtotal ;Penalties ;Instrument-Instrument Collisions ;Incorrect Rings ;Cone Collisions ;Instrument-Endoscope Cottisions ;Endoscope-Environment Collisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Value ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 sec. ;1.0 ct. ;0.0 ct. ;Penalty Subtotal ;Overall Score ;pts. ;39.9 ;31.7 ;72 ;pts. ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-2.0 ;-0.0 ;.2 ;70 ; """# let stringRange = NSRange(location: 0, length: testString.utf16.count) let matches = regex.matches(in: testString, range: stringRange) var result: [[String]] = [] for match in matches { var groups: [String] = [] for rangeIndex in 1 ..< match.numberOfRanges { let nsRange = match.range(at: rangeIndex) guard !NSEqualRanges(nsRange, NSMakeRange(NSNotFound, 0)) else { continue } let string = (testString as NSString).substring(with: nsRange) groups.append(string) } if !groups.isEmpty { result.append(groups) } } print(result)

Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Swift 5.2, please visit: https://developer.apple.com/documentation/foundation/nsregularexpression