     }
 
 
-    static func preg_replace (pattern: String, _ replacement: String, _ subject: [String], _ limit: Int = -1) -> [String] {
+    public static func preg_replace (pattern: String, _ replacement: String, _ subject: [String], _ limit: Int = -1) -> [String] {
         var r=[String]()
         for subSubject in subject {
             r.append(preg_replace(pattern, replacement, subSubject, limit))

        return string.substringWithRange(startIndex! ..< endIndex)
    }

    static func strlen(string: String) -> Int {
        return string.characters.count
    }

    static func lcfirst(string: String) -> String {
        var tstring=string
        let first=tstring.firstCharacterRange()
        tstring.replaceRange(first, with:tstring.substringWithRange(first).lowercaseString)
        return tstring
    }

    static func ucfirst(string: String) -> String {
        var tstring=string
        let first=tstring.firstCharacterRange()
        tstring.replaceRange(first, with:tstring.substringWithRange(first).uppercaseString)


    static let PREG_OFFSET_CAPTURE=1

    public static func preg_match(pattern: String, _ subject: String, inout _ matches: [String], _ flags: Int = 0, _ offset: Int = 0) -> Int {
        let subjectWithOffset=substr(subject, offset, strlen(subject))
        if subjectWithOffset.isMatching(pattern) {
            return 1
        }
        return 0
    }

    public static func preg_replace (pattern: String, _ replacement: String, _ subject: String, _ limit: Int = -1) -> String {
        do {
            let regex = try NSRegularExpression(pattern: pattern, options: [.CaseInsensitive])
            return regex.stringByReplacingMatchesInString(subject, options: [], range: NSMakeRange(0, strlen(subject)), withTemplate:replacement)
