regex-simple-checks
v1.0.5
Published
Common regex checks that you can use in the JavaScript world without looking for them and making sure they work!
Maintainers
Readme
Common regex checks that you can use in the JavaScript world without looking for them on Google!
Features:
- Some common regex checks that we all need to do sometimes. :blush:
- Call the functions as per your need and a boolean value is returned.
- Light weight package.
- Many useful functions in the package.
How to install:
npm i regex-simple-checks
How to use:
- Import the package into your application as usual
import {containOnlyLetters} from '@gurjinder7/regex-simple-checks'
- Checking functions that return boolean:
containAnyDigits(pattern)- returnstrueis the pattern contains a digitcontainsAnyNonWordCharacter(pattern)- returnstrueif the pattern contains any non word character.- This is a broad search for symbols and includes whitespace as well.
containOnlyLetters(pattern)- returnstrueif pattern contains only letterscontainsNoSymbol(pattern)- returnstrueif patterns has no symbol- Can be used for alphanumeric pattern or only number and only digits patterns
containsAnySymbol(pattern)- returnstrueif one of the following symbol is there in the pattern~`!@#$%^&*()_-+=|\}{]["':;<,>.?/
containsThisSymbol(pattern, symbol)- returnstrueif the pattern contains the symbol.containsThisSymbol("qwe%asd","%")- returnstrue
containsThisOrThatSymbol(pattern, symbol1, symbol2)- returnstrueif the pattern contains either of the symbolscontainsThisOrThatSymbold("jhkgjh&kKJh","@","&") - returnstrue`
startsWithADigitAndEndsWithALetter(pattern)- returnstrueif the patterns starts and ends with one or more than one digit.- pattern :
digits-letters - Eg:
12asdlkaskd,2asdaetc.
- pattern :
startsWithALetterAndEndsWithADigit(pattern)- returnstrueif the pattern starts with a letter and ends with a digit.- one or more than one letter and one or more than one digit.
- pattern :
letters-digits - Eg:
aada112,a2323,asda3
startsWithADigitAndEndsWithADigit(pattern)- returnstrueif the pattern start with a digit and ends with a digit.- one or more than one digit on both ends.
- pattern :
digits-letters-digits - Eg:
2asde2,23asdssad12
startsWithALetterAndEndsWithALetter(pattern)- returnstrueif the pattern start and ends with one or more letter.- pattern :
letters-digits-letters - Eg;
asd332asd,a32423432a
- pattern :
- Match function that returns index:
firstDigitMatchIndex(pattern)- returns index of first match of the digit in the pattern, otherwise-1firstNonWordMatchIndex(pattern)- returns index of first match of the non-word in the pattern, otherwise-1firstWhiteSpaceMatchIndex(pattern)- returns index of first match of the white space in the pattern, otherwise-1firstSymbolMatchIndex(pattern, symbol)- returns index of first match of the symbol argument in the pattern, otherwise-1
