Format numbers using a string pattern with this simple number formatted like ##-####-##

Overview

AndroidPattern

jitpack FOSSA Status

Format numbers using a string pattern with this simple number formatted like ##-####-##

Installation

To get a Git project into your build: Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

buildscript {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Step 2. Add the dependency

implementation "com.github.Husseinhj:AndroidPattern:1.0.1"

Digit format

By default, numbers are defined by the # character and if you want to customize the format, use the digitPatterns property as shown in the following code:

AndroidPattern.digitPatterns = charArrayOf('#', '$', '*')

Sample

Mobile format:

val pattern = "98### ### ####"
val applied = "9121234567".applyPattern(pattern, exactPattern = true)

print(applied)

// 98912 123 4567

Postal code format:

val pattern = "#####-#####"
val applied = "4173412121".applyPattern(pattern)

print(applied)

// 41734-12121

Separator format:

val pattern = "###,###,###,###"
val applied = 123456789.applyPattern(pattern, exactPattern = true)

print(applied)

// 123,456,789

License

FOSSA Status

You might also like...
A lightweight library for config and using SharedPreferences

preferences-helper SharePreferences is very popular with any project and all most all project has SharePreferences for saving data. This library will

recompose is a tool for converting Android layouts in XML to Kotlin code using Jetpack Compose.
recompose is a tool for converting Android layouts in XML to Kotlin code using Jetpack Compose.

recompose is a tool for converting Android layouts in XML to Kotlin code using Jetpack Compose.

This project is an add-on for the excellent J2V8 Project. It allows users to debug JS running in V8 using Chrome DevTools. Uses Stetho for communication with Chrome DevTools.

J2V8-Debugger This project is an add-on for the excellent J2V8 Project. It allows users to debug JS running in V8 using Chrome DevTools. Uses Stetho f

Generate helper methods for compose navigation using KSP

Compose NavGen Generate helper methods for compose navigation using KSP. 🚧 You can try it now, but it's still under development. 🚧 TODO Support defa

Extensions to encrypt DataStore using Tink

encrypted-datastore Extensions to encrypt DataStore using Tink. ⚠️ This tiny library will be maintained until an official solution for DataStore encry

Android injection using the Anvil compiler plugin

Tangle creates Dagger bindings for Android classes using the Anvil Kotlin compiler plugin. This is meant to be an alternative to Hilt, for those who'd prefer to enjoy the faster compilation and better flexibility of Anvil.

DEMOMovieDB - Client App using movieDB with Kotlin
DEMOMovieDB - Client App using movieDB with Kotlin

DEMOMovieDB DEMOMovieDB is a gorgeous client application for TMDb on Android, bu

λRPC allows using code with high-order functions as a service
λRPC allows using code with high-order functions as a service

λRPC Simple native RPC with high order functions support. Inspired by @altavir and Communicator. λRPC allows using code with high-order functions as a

A universal memory dumper using Frida

Fridump Fridump (v0.1) is an open source memory dumping tool, primarily aimed to penetration testers and developers. Fridump is using the Frida framew

Comments
Releases(1.0.2)
Owner
Hussein Habibi Juybari
Software Engineer
Hussein Habibi Juybari
Phrase is an Android string resource templating library

Phrase - Android string formatting CharSequence formatted = Phrase.from("Hi {first_name}, you are {age} years old.") .put("first_name", firstName)

Square 1.4k Dec 9, 2022
Fuzzy string matching for Kotlin (JVM, native, JS, Web Assembly) - port of Fuzzy Wuzzy Python lib

FuzzyWuzzy-Kotlin Fuzzy string matching for Kotlin (JVM, iOS) - fork of the Java fork of of Fuzzy Wuzzy Python lib. For use in on JVM, Android, or Kot

WillowTree, LLC 54 Nov 8, 2022
A library for calculating on string data.

FookCalc What is FookCalc? A library for calculating on string data. Gradle Add the following to your project's root build.gradle file repositories {

Halil ibrahim EKİNCİ 10 Aug 15, 2022
CHAOS - Like a utility knife for discord

CHAOS - Like a utility knife for discord. Currently under development. If you feel inclined, please support me by contributing to this project. Or alt

caffeine.moe 20 Nov 13, 2022
A simple library for validating user input in forms using annotations.

ValidationKomensky for Android A simple library for validating user input in forms using annotations. Features: Validate all views at once and show fe

Inmite s.r.o. 512 Nov 20, 2022
Trail is a simple logging system for Java and Android. Create logs using the same API and the library will detect automatically in which platform the code is running.

Trail Trail is a simple logging system for Java and Android. Create logs using the same API and the library will detect automatically in which platfor

Mauricio Togneri 13 Aug 29, 2022
Simple-Claim-Form - Android App for creating a simple dynamic form with MVVM architecture

Simple-Claim-Form Android App for creating a simple dynamic form with MVVM archi

Shubham Gangpuri 1 Aug 14, 2022
Android library to easily serialize and cache your objects to disk using key/value pairs.

Deprecated This project is no longer maintained. No new issues or pull requests will be accepted. You can still use the source or fork the project to

Anup Cowkur 667 Dec 22, 2022
A set of helper classes for using dagger 1 with Android components such as Applications, Activities, Fragments, BroadcastReceivers, and Services.

##fb-android-dagger A set of helper classes for using dagger with Android components such as Applications, Activities, Fragments, BroadcastReceivers,

Andy Dennie 283 Nov 11, 2022
Android Secure SharedPreferences Using Facebook Conceal Encryption

SharedChamber Android Project : SharedChamber on top of SharedPreferences using Facebook Conceal Description Conceal provides a set of Java APIs to pe

Hafiq 95 Nov 25, 2022