Skip to content

Commit

Permalink
switch .replaceAll.trimEnd with regex replace
Browse files Browse the repository at this point in the history
  • Loading branch information
kjloveless committed Nov 14, 2024
1 parent 5b796bc commit 70df5a6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,12 @@ function editorOpen(filename: string) {
console.log(`filename: ${filename}`);
e.filename = filename;
const data = Deno.readFileSync(filename);
const contents = decoder.decode(data).replaceAll("\r", "").trimEnd();
// /\s+$/
// \s+ -> matches one or more whitespace characters, including spaces, tabs,
// newlines, and carraige returns
// $ -> anchors the match to the end of the string
// '' -> replaces the matched whitespace chars with an empty string
const contents = decoder.decode(data).replace(/\s+$/, "");
const lines = contents.split("\n");

let i = 0;
Expand Down

0 comments on commit 70df5a6

Please sign in to comment.