Skip to main content

正規表現 - RegExp

swift
  if let m = name.firstMatch(of: /^(.*) *\((.*)\)$/) {
let parkName = m.output.1
let parkLocation = m.output.2
}
swift
  let re = /^(.*?)\s*([0-9\.]+(?:\.[0-9]+)?)$/
if let m = try! re.wholeMatch(in: event.title) {
let s = String(m.output.1)
let v = Double(m.output.2)

multiline のスイッチ相当

swift
let re = /^(- |\* |#+ |^\`)/.anchorsMatchLineEndings()