string-jaws
v1.2.6
Published
This Angular Module adds the ability to rip strings apart from Chars, Words, Items and Lines.
Downloads
75
Maintainers
Readme
StringJaws
This Angular Module adds the ability to rip strings apart from Chars, Words, Items and Lines.
Installation
npm install string-jaws
Scaffolding
Import the module into your project under imports
imports: [
BrowserModule,
AppRoutingModule,
StringJawsModule
],
Use
In your component file, import the module in the contructor
private jaws: StringJaws
Then call any of the functions, like the eample below
this.jaws.specs.details(this.title)
Here is a sample of a component setup
export class AppComponent implements OnInit {
constructor(
private jaws: StringJaws
) {}
title = 'sampleTestApp'
ngOnInit() {
const found = this.jaws.helpers.findIndex(this.title, 'test', true)
console.log(found)
const temp = this.jaws.specs.details(this.title)
console.log(temp)
}
}
String Functions
Anything and everthing you need to for string manipulation - the list of fuctions are below const me know if you need anything else to add :)
Validations
console.log('isChar:', this.jaws.isChar('a'))
console.log('isCharLC:', this.jaws.isCharLowerCase('a'))
console.log('isCharUC:', this.jaws.isCharUpperCase('a'))
console.log('isCharSP:', this.jaws.isSpecial('!'))
console.log('isInt:', this.jaws.isInt('1'))
console.log('isFloat:', this.jaws.isFloat('1'))
console.log('isNothing:', this.jaws.isNothing(''))
console.log('isSpace:', this.jaws.isSpace(' '))
Chracters
console.log('chars:', this.jaws.chars('sample'))
const cnt = this.jaws.charCount('Mike Was Here')
console.log('count:',cnt)
const charPos = this.jaws.char('Boni',2) //n
console.log('charPos:',charPos)
const charRange = this.jaws.charRange('Boni',2,4) //nifa
console.log('charRange:',charRange)
console.log('fChar:', this.jaws.charFirst('Mike Was Here'))
console.log('lChar:', this.jaws.charLast('Mike Was Here'))
console.log('fChar-range of 2:', this.jaws.charFirst('Mike Was Here',2)) //Mik
console.log('lChar-range of 4:', this.jaws.charLast('Mike Was Here',4)) //Here
console.log('Found Char e:', this.jaws.charFound('Mike Was Here','e')) //true/false
console.log('Found Char Count "e":', this.jaws.charFoundCount('Mike Was Here','e')) //int 3
console.log('Found Char "e" Indexs:', this.jaws.charFoundIndexs('Mike Was Here','e')) //[ 3, 10, 12 ]
console.log('Delete Char:', this.jaws.charDeleteAt('Mike Was Here', 2))
console.log('Insert Char:', this.jaws.charInsertAt('MikeBoni', 4, '-'))
console.log('Replace Char:', this.jaws.charReplaceAt('Mike-', 4, 'B'))
console.log('Find Char Index:', this.jaws.charFindIndex('Mike Boni', 'B'))
console.log('Find Char and Replace:', this.jaws.charReplace('Mike - Boni', '-', ':'))
console.log('charRepeat:', this.jaws.charRepeat('w',3))
console.log('Delete Char "a":', this.jaws.charDelete('Mike Was Here. Yes he was Here', 'a'))
console.log('Delete All Char "a":', this.jaws.charDelete('Mike Was Here. Yes he was Here', 'a', true))
Words
const words = this.jaws.words('Mike Was Here')
console.log('words:',words)
const wordCount = this.jaws.wordCount('Mike Was Here')
console.log('wordCount:',wordCount)
const wordPos = this.jaws.word('Mike Was Here',1) //Was
console.log('WordPos:',wordPos)
const wordRange = this.jaws.wordRange('Mike Was Here',1,2) //Was Here
console.log('wordRange:',wordRange)
const fWord = this.jaws.wordFirst('Mike Was Here')
console.log('fWord:',fWord)
const lWord = this.jaws.wordLast('Mike Was Here')
console.log('lWord:',lWord)
const fWordRange = this.jaws.wordFirst('Mike Was Here Today At Home', 2)
console.log('fWord-range of 2:',fWordRange)
const lWordRange = this.jaws.wordLast('Mike Was Here Today At Home', 2)
console.log('lWord-range of 2:',lWordRange)
console.log('wordFind:', this.jaws.wordFound('Mike Was Here', 'Was'))
console.log('Found Word Count "was":', this.jaws.wordFoundCount('Mike Was Here. Yes he was Here','was')) //int 2
console.log('Found Word "was" Indexs:', this.jaws.wordFoundIndexs('Mike Was Here. Yes he was Here','was')) //[ 1, 5 ]
console.log('Delete Word "Boni" idx 2:', this.jaws.wordDeleteAt('Mike Was Boni. Yes was here!', 2)) //Boni is deleted
console.log('Insert Word: "Hello" idx 2:', this.jaws.wordInsertAt('Mike Was Boni. Yes was here!', 2, 'Hello'))
console.log('Replace Word: "Boni" w "Boni" idx 2:', this.jaws.wordReplaceAt('Mike Was Boni. Yes was here!', 2, 'Boni'))
console.log('Find Word Index:', this.jaws.wordFindIndex('Mike Boni Was Here', 'was'))
console.log('Find Word and Replace:', this.jaws.wordReplace('Mike NOT Here', 'not', 'IS'))
console.log('wordRepeat:', this.jaws.wordRepeat('Mike Was Here',3))
console.log('Delete Word "was":', this.jaws.wordDelete('Mike Was Here. Yes he was Here', 'was'))
console.log('Delete All Words "was":', this.jaws.wordDelete('Mike Was Here. Yes he was Here', 'was', true))
Items (Delimeter)
const items = this.jaws.items('Mike, Was, Here')
console.log('items:',items)
const itemCount = this.jaws.itemCount('Mike, Was, Here')
console.log('itemCount:',itemCount)
const itemPos = this.jaws.item('Mike, Was, Here',1) //Was
console.log('itemPos:',itemPos)
const itemRange = this.jaws.itemRange('Mike, Was, Here',1,2) //Was Here
console.log('itemRange:',itemRange)
const fitem = this.jaws.itemFirst('Mike, Was, Here')
console.log('fitem:',fitem)
const litem = this.jaws.itemLast('Mike, Was, Here')
console.log('litem:',litem)
const fitemRange = this.jaws.itemFirst('Mike Was, Here Today, At Home', 2)
console.log('fitem-range of 2:',fitemRange)
const litemRange = this.jaws.itemLast('Mike Was, Here Today, At Home', 2)
console.log('litem-range of 2:',litemRange)
console.log('itemFind:', this.jaws.itemFound('Mike, Was, Here', 'was'))
console.log('Found item Count "was":', this.jaws.itemFoundCount('Mike,Was,Here.,Yes,he,was,Here','was')) //int 2
console.log('Found item "was" Indexs:', this.jaws.itemFoundIndexs('Mike,Was,Here.,Yes,he,was,Here','was')) //[ 1, 5 ]
console.log('Delete item "Boni" idx 2:', this.jaws.itemDeleteAt('Mike, Was, Boni., Yes, was, here!', 2)) //Boni is deleted
console.log('Insert item: "Hello" idx 2:', this.jaws.itemInsertAt('Mike, Was, Boni. Yes, was, here!', 2, 'Hello'))
console.log('Replace item: "Boni" w "Boni" idx 2:', this.jaws.itemReplaceAt('Mike, Was, Boni., Yes, was, here!', 2, 'Boni'))
console.log('Find item Index:', this.jaws.itemFindIndex('Mike, Boni, Was, Here', 'was'))
console.log('Find item and Replace:', this.jaws.itemReplace('Mike, NOT, Here', 'not', 'IS'))
console.log('itemRepeat:', this.jaws.itemRepeat('Mike, Was, Here',3))
console.log('Delete items "was":', this.jaws.itemDelete('Mike, Was, Here., Yes, he, was, Here', 'was'))
console.log('Delete All items "was":', this.jaws.itemDelete('Mike,Was,Here.,Yes,he,was,Here', 'was', true))
Lines
console.log('lines:',this.jaws.lines('Mike/nWas/nHere'))
console.log('lineCount:',this.jaws.lineCount('Mike/nWas/nHere'))
const linePos = this.jaws.line('Mike/nWas/nHere',1) //Was
console.log('linePos:',linePos)
const lineRange = this.jaws.lineRange('Mike/nWas/nHere',1,2) //Was Here
console.log('lineRange:',lineRange)
const fline = this.jaws.lineFirst('Mike/nWas/nHere')
console.log('firstline:',fline)
const lline = this.jaws.lineLast('Mike/nWas/nHere')
console.log('lastline:',lline)
const RFlineRange = this.jaws.lineFirst('Mike Was/nHere Today/nAt Home', 2)
console.log('line-range of 2:',RFlineRange)
const RLlineRange = this.jaws.lineLast('Mike Was/nHere Today/nAt Home', 2)
console.log('line-range of 2:',RLlineRange)
console.log('Delete item "Boni" idx 2:', this.jaws.lineDeleteAt('Mike/nWas/nBonifacio./nYes/nwas/nhere!', 2)) //Boni is deleted
console.log('Insert item: "Hello" idx 2:', this.jaws.lineInsertAt('Mike/nWas/nBonifacio./nYes/nwas/nhere!', 2, 'Hello'))
console.log('Replace item: "Boni" w "Boni" idx 2:', this.jaws.lineReplaceAt('Mike/nWas/nBonifacio./nYes/nwas/nhere!', 2, 'Boni'))
Miscellaneous
console.log('getNumbers:',this.jaws.getNumbers())
console.log('getChars:',this.jaws.getChars())
console.log('getSpecial:',this.jaws.getSpecial())
console.log('padded:', this.jaws.pad('12',2, '0'))
console.log('lPadded:', this.jaws.padLeft('12',2, '0'))
console.log('rPadded:', this.jaws.padRight('12',2, '0'))
console.log('cleanSpecial:', this.jaws.cleanSpecial('ABCDefghIJKLmnopQRSTUVwxyz1234567890!@#$%^&*()_+-={}[]|\:;<>,.?`~'))
console.log('cleanNumbers:', this.jaws.cleanNumbers('ABCDefghIJKLmnopQRSTUVwxyz1234567890!@#$%^&*()_+-={}[]|\:;<>,.?`~'))
console.log('cleanAlpha:', this.jaws.cleanAlpha('ABCDefghIJKLmnopQRSTUVwxyz1234567890!@#$%^&*()_+-={}[]|\:;<>,.?`~'))
console.log('strRepeat:', this.jaws.strRepeat('WOW 123',2, ' '))
console.log('deleteAt:', this.jaws.deleteAt('Mike Was - Here',1,'-'))
console.log('insertAt:', this.jaws.insertAt('Mike Was - Here',1, 'WOW', '-'))
console.log('replaceAt:', this.jaws.replaceAt('Mike Was - Here',1, 'WOW', '-'))
console.log('findIndex:', this.jaws.findIndex('Mike Was - Here Me','Here'))
Specs
console.log('Mike Boni SampleSecrete123!')
const specs = this.jaws.specs.details('Mike Boni SampleSecrete123!')
console.log('Specs:', specs)