Permalink
Browse files

Removed Regexkit because of old and not mainatained anymore

Added also cocoapod support (no pods at the moment)
  • Loading branch information...
mgmart committed Dec 14, 2016
1 parent 3111a85 commit 30f29d66b103a50e1d751fa2f50202f361d36f9a
View
@@ -25,7 +25,7 @@
#import "DataUtils.h"
#import "Settings.h"
#import "GlobalUtils.h"
#import "RegexKitLite.h"
#import "MobileOrg-Swift.h"
@implementation Node
@@ -0,0 +1,93 @@
//
// String+RegexSplitter.swift
// MobileOrg
//
// Created by Mario Martelli on 12.12.16.
//
//
import Foundation
public extension NSString {
func componentsSeparatedBy(regex: String) -> Array<String> {
do {
var result:[String] = []
let swiftString = String(self)
let rgx = try NSRegularExpression(pattern: regex, options: [])
let matches = rgx.matches(in: swiftString, options: [], range: NSRange(location: 0, length: swiftString.characters.count))
for match in matches {
for n in 0..<match.numberOfRanges {
let range = match.rangeAt(n)
let begin = swiftString.index(swiftString.startIndex, offsetBy: range.location)
let end = swiftString.index(swiftString.startIndex, offsetBy: range.location+range.length)
result.append(swiftString.substring(with: begin..<end))
}
}
return result
} catch {
return []
}
}
func arrayOfCaptureComponentsMatchedBy(regex: String) -> Array<Array<String>> {
let capture = self.captureComponentsMatchedBy(regex: regex)
if capture.count > 0 {
let ret:[Array<String>] = [capture]
return ret
}
return []
}
func captureComponentsMatchedBy(regex: String) -> Array<String> {
do {
var result:[String] = []
let swiftString = String(self)
let rgx = try NSRegularExpression(pattern: regex, options: [])
let matches = rgx.matches(in: swiftString, options: [], range: NSRange(location: 0, length: swiftString.characters.count))
for match in matches {
for n in 0..<match.numberOfRanges {
let range = match.rangeAt(n)
let begin = swiftString.index(swiftString.startIndex, offsetBy: range.location)
let end = swiftString.index(swiftString.startIndex, offsetBy: range.location+range.length)
result.append(swiftString.substring(with: begin..<end))
}
}
return result
} catch {
return []
}
}
func rangeOf(regex: String) -> NSRange {
let range = NSMakeRange(0, self.length)
let match = self.range(of: regex, options: .regularExpression, range: range)
return match
}
func isMatchedBy(regex: String) -> Bool {
let range = NSMakeRange(0, self.length)
let match = self.range(of: regex, options: .regularExpression, range: range)
if match.location == NSNotFound {
return false
}
return true
}
func stringByReplacingOccurrencesOf(regex: String, withString: String) -> String {
let rgx = try! NSRegularExpression(pattern: regex,
options: NSRegularExpression.Options.caseInsensitive)
let range = NSMakeRange(0, self.length)
let modString = rgx.stringByReplacingMatches(in: self as String,
options: [],
range: range,
withTemplate: withString)
return modString
}
}
@@ -25,6 +25,8 @@
#import "LocalEditAction.h"
#import "DataUtils.h"
#import "GlobalUtils.h"
#import "MobileOrg-Swift.h"
@implementation NodeTextEditController
@@ -21,7 +21,7 @@
//
#import "ChecksumFileParser.h"
#import "RegexKitLite.h"
#import "MobileOrg-Swift.h"
@implementation ChecksumFileParser
@@ -24,7 +24,8 @@
#import "EditEntity.h"
#import "DataUtils.h"
#import "GlobalUtils.h"
#import "RegexKitLite.h"
#import "MobileOrg-Swift.h"
@implementation EditsFileParser
@@ -25,7 +25,8 @@
#import "GlobalUtils.h"
#import "DataUtils.h"
#import "Settings.h"
#import "RegexKitLite.h"
#import "MobileOrg-Swift.h"
@implementation OrgFileParser
@@ -29,7 +29,8 @@
#import "Settings.h"
#import "GlobalUtils.h"
#import "DropboxTransferManager.h"
#import "RegexKitLite.h"
#import "MobileOrg-Swift.h"
// Singleton instance
static Settings *gInstance = NULL;
@@ -35,6 +35,7 @@
#import "SessionManager.h"
#import "MobileOrgAppDelegate.h"
#import "DropboxTransferManager.h"
#import "MobileOrg-Swift.h"
@implementation SettingsController
@@ -36,7 +36,8 @@
#import "LocalEditAction.h"
#import "StatusViewController.h"
#import "MobileOrgAppDelegate.h"
#import "RegexKitLite.h"
#import "MobileOrg-Swift.h"
@interface SyncManager(private)
- (TransferManager*)transferManager;
@@ -0,0 +1,4 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
Oops, something went wrong.

0 comments on commit 30f29d6

Please sign in to comment.