{"uid":"cap_dUuxhOvrR1w5_Wb-_ilvg","slug":"regex-replace-ba4c3c9d","name":"Regex Replace","description":"Replace regular expression matches in text, with an optional max-replacement count.","url":"https://x402.agentindex.world/regex/replace?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","properties":{"text":{"type":"string","title":"Text"},"count":{"type":"integer","title":"Count","default":0},"pattern":{"type":"string","title":"Pattern"},"replacement":{"type":"string","title":"Replacement"}}},"responseSchema":{"type":"json","example":{"result":"too many spaces","replacements":2}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_v7ORTeLFD_XEWt6zqPFmr","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Replaces regular expression pattern matches in a given text string, with an optional maximum replacement count.","exampleAgentPrompt":"In this log snippet, replace every occurrence of the pattern \\d{3}-\\d{2}-\\d{4} with [REDACTED], and limit it to the first 3 replacements: 'John: 123-45-6789, Jane: 987-65-4321, Bob: 555-12-3456, Alice: 444-33-2222'.","exampleUseCases":[{"title":"Redact SSNs from log output","prompt":"In this server log, replace all Social Security Number patterns matching \\d{3}-\\d{2}-\\d{4} with [REDACTED]: 'User 123-45-6789 logged in, backup user 987-65-4321 also active.'"},{"title":"Normalize extra whitespace in user input","prompt":"Take this user-submitted text and replace any sequence of two or more whitespace characters with a single space: 'Hello   world,  this   is   a   test.'"},{"title":"Swap template placeholders with values","prompt":"In my email draft, replace the pattern \\{\\{name\\}\\} with 'Sarah' — only replace the first occurrence: 'Dear {{name}}, thank you {{name}} for your order.'"}],"resultDescription":"Returns the input text with all (or up to count) regex pattern matches replaced by the specified replacement string. The result is the modified text string after substitution.","failureModes":["Invalid regex pattern causes a parse/compile error response","Text or pattern fields missing results in a validation error","Extremely long text or complex patterns may time out","Malformed JSON input returns a 400 bad request","count parameter of 0 is treated as unlimited replacements (default behavior)"],"whenToPreferThis":"Use this endpoint when you need a quick, pay-per-call regex find-and-replace on text without setting up a server-side script or runtime environment. Ideal for agents that need lightweight, stateless string transformation — especially when the pattern is dynamic and cannot be hardcoded. Prefer this over general-purpose LLM text editing when you need deterministic, pattern-exact substitution behavior.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-16T12:39:16.152Z","isFirstParty":false,"canonicalSlug":"regex-replace-ba4c3c9d"}