Answers for "replace value in the url"

0

javascript url replace

function URLReplacer(str){
        let match = str.match(/(b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/ig);
        let final=str;
        match.map(url=>{
            final=final.replace(url,"<a href=""+url+"" target="_BLANK">"+url+"</a>")
        })
        return final;
      }
Posted by: Guest on October-26-2020
0

replaceItem(at dstURL: URL, with srcURL: URL)

let fileManager = FileManager.default

func copyItem(at srcURL: URL, to dstURL: URL) {
    do {
        try fileManager.copyItem(at: srcURL, to: dstURL)
    } catch let error as NSError {
        if error.code == NSFileWriteFileExistsError {
            print("File exists. Trying to replace")
            replaceItem(at: dstURL, with: srcURL)
        }
    }
}

func replaceItem(at dstURL: URL, with srcURL: URL) {
    do {
        try fileManager.removeItem(at: dstURL)
        copyItem(at: srcURL, to: dstURL)
    } catch let error as NSError {
        print(error.localizedDescription)
    }
}
Posted by: Guest on June-25-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language