regexp-replace
v1.0.2
Published
base on RegExp#exec instead of String#replace
Downloads
11
Maintainers
Readme
regexp-replace
base on RegExp#exec instead of String#replace.
Usage
const case = '<view class="p-[20px] -mt-2 mb-[-20px]">test case</view>'
const regex = /(?:class|className)=(?:["']\W+\s*(?:\w+)\()?["']([^"]+)['"]/gim
// remove class
replace(case, regex, (match, arr, idx, lastIdx, str) => {
return ''
})
// sign
function replace(str: string, pattern: RegExp, replacement: string | ((match: string, arr: RegExpExecArray, index: number, lastIndex: number, string: string) => string)): string;
// params
// match -> RegExp match string
// arr -> RegExpExecArray
// index -> RegExpExecArray#index
// lastIndex -> RegExp#lastIndex
// string -> orignal string
More Usages see here