ITADN

@std/regex: `replaceAllAsync`

#7030Openlionel-rowe 创建于 2026-03-04
L
lionel-rowecommented
**Is your feature request related to a problem? Please describe.** Sometimes you wanna replace regex matches but the thing you want to replace them with needs to be fetched asynchronously (web resource, db query, file read, etc.) **Describe the solution you'd like** Example: ```ts const result = await replaceAllAsync( 'https://example.com/ and https://example.com/not-found!', /https:\/\/([\w\-/.]+)/g, async (match, address) => { const { status } = await fetch(match, { method: 'HEAD' }) return `${address} returned status ${status}` }, ) assertEquals( result, 'example.com/ returned status 200 and example.com/not-found returned status 404!', ) ``` **Describe alternatives you've considered** N/A
0 条评论