Skip to content

TehShrike/better-replace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

better-replace

  • No need to remember to add g every time
  • Less junk passed to the replacer function
npm i better-replace
betterReplace(
	/'(\w)/,
	char => `'${char}${char}${char}`,
	`How's it going y'all?  What's the haps`
) // => `How'sss it going y'aaall?  What'sss the haps`

betterReplace(
	/(\d):(\d)/g,
	(first, second) => `${second}-${first}`,
	'1:2 3:4'
) // => '2-1 4-3'

License

WTFPL

About

Use regular expressions to replace things in strings!

Resources

Stars

Watchers

Forks

Packages

No packages published