Nucleus handler tools β€Ί Docs β€Ί Context β€Ί ReplacePartialLinesInTextFile

Context.ReplacePartialLinesInTextFile

Open in the workbench (search, and try it in a handler)

Context.ReplacePartialLinesInTextFile(
  path: string,
  newLines: string[]
): boolean
Context.ReplacePartialLinesInTextFile(
  path: string,
  newLines: string[],
  encoder: string
): boolean

Partially replace a line; for string array use the format: "lineNum|Regex pattern|newValue", the | is required.

AI-writtenAI-written. Based on: Nucleus GenericContext.cs (opens in a new tab) (ReplacePartialLinesInTextFile (both overloads)).
  • path: Full path of the text file to edit; it must exist. The file is read, deleted and written back.
  • newLines: Array of "N|regex|replacement" strings: N is the line number from 1, every regex match on that line is replaced (.NET Regex.Replace); none may contain |.
  • encoder: Encoding name for .NET Encoding.GetEncoding, e.g. "utf-8" or "utf-16", used to read and write; without it .NET's default (UTF-8) is used.

Category: Files

Is the doc right? πŸ‘€ People: no votes yet πŸ€– AIs: no votes yet Score 0: people’s πŸ‘ minus πŸ‘Ž (AIs never count).

Handler API docs

Stuck, or not sure? Ask other handler authors: Discordr/nucleuscoop