{"id":15037381,"url":"https://github.com/orucanil/stringformatter","last_synced_at":"2025-04-13T04:14:59.875Z","repository":{"id":197644544,"uuid":"97939351","full_name":"orucanil/StringFormatter","owner":"orucanil","description":"Simple Text Formetter (Credit Card Number, Phone Number, Serial Number etc.) Can be used in all text inputs according to the format pattern. If desired, large minor character restrictions can be made in the format pattern.","archived":false,"fork":false,"pushed_at":"2022-01-11T14:34:22.000Z","size":29,"stargazers_count":252,"open_issues_count":3,"forks_count":21,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-13T04:14:51.686Z","etag":null,"topics":["character","character-restrictions","credit-card","creditcard-validator","formatter","ios","phone-format","phone-number","stringformatter","stringformatter-extension","swift","swift3","swift4","swift5","text-formetter","textfield","textview","validator"],"latest_commit_sha":null,"homepage":"https://www.linkedin.com/in/annul","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/orucanil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-21T11:09:13.000Z","updated_at":"2024-12-16T09:30:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"b94be3e0-5bed-4194-bc7e-cee3388e93c4","html_url":"https://github.com/orucanil/StringFormatter","commit_stats":null,"previous_names":["orucanil/stringformatter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orucanil%2FStringFormatter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orucanil%2FStringFormatter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orucanil%2FStringFormatter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orucanil%2FStringFormatter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orucanil","download_url":"https://codeload.github.com/orucanil/StringFormatter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248661718,"owners_count":21141451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["character","character-restrictions","credit-card","creditcard-validator","formatter","ios","phone-format","phone-number","stringformatter","stringformatter-extension","swift","swift3","swift4","swift5","text-formetter","textfield","textview","validator"],"created_at":"2024-09-24T20:34:28.838Z","updated_at":"2025-04-13T04:14:59.855Z","avatar_url":"https://github.com/orucanil.png","language":"Swift","readme":"# StringFormatter\n\nSimple Text Formatter (Credit Card Number, Phone Number, Serial Number etc.) Can be used in all text inputs according to the format pattern. If desired, large minor character restrictions can be made in the format pattern.\n\nTextFieldFormatter : https://github.com/orucanil/TextFieldFormatter\n\n## Display Visual Example \n\n----\n![Visual1](http://g.recordit.co/BAaWSNTpZK.gif)\n\n\nInstallation\n--------------\n\nTo use the StringFormatter extension in an app, just drag the StringFormatter extension file (demo files and assets are not needed) into your project.\n\n\nMethods\n--------------\n\nThe StringFormatter extension has the following methods (note: for iOS, String in method arguments):\n\n* func format(_ format: String, oldString: String) -\u003e String\n\nFormatting method according to given format pattern. oldString can be empty(\"\"), but the final character formatting may not work smoothly.\n\n* func unformat(_ format: String, oldString: String) -\u003e String\n\nUnformatting method according to given format pattern. oldString can be empty(\"\"), but the final character unformatting may not work smoothly.\n\n\nHow to use ?\n----------\n\nIf the text format is entered uppercase, the character input from the keyboard is displayed as a upper case character.\n\n'x' or 'X' -\u003e Any character\n\n'c' or 'C' -\u003e Alphabetic character\n\n'n' or 'N' -\u003e Numerical character\n\n\n```Swift\n\n\nextension ViewController: UITextFieldDelegate {\nfunc textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -\u003e Bool {\n\nguard let text = textField.text else {\nreturn true\n}\nlet lastText = (text as NSString).replacingCharacters(in: range, with: string) as String\n\nif textfieldPhoneNumber == textField {\ntextField.text = lastText.format(\"(NNN) NNN NN NN\", oldString: text)\nreturn false\n} else if textfieldCreditCard == textField {\ntextField.text = lastText.format(\"nnnn nnnn nnnn nnnn\", oldString: text)\nreturn false\n} else if textfieldSerialNumber == textField {\ntextField.text = lastText.format(\"XX NNNN\", oldString: text)\nreturn false\n}\nreturn true\n}\n}\n\n\n```\n\nBuild and run the project files. Enjoy more examples!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forucanil%2Fstringformatter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forucanil%2Fstringformatter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forucanil%2Fstringformatter/lists"}