Skip to content

Commit

Permalink
Extract a common expression into a variable/const.
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomif committed Dec 3, 2023
1 parent c6c83f1 commit e57a33f
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions fc-solve/site/wml/src/ts/web-fc-solve--expand-moves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,28 +326,29 @@ export function fc_solve_expand_moves_filter_solution_text(
const board2move_sep = "\n\n====================\n\n";
const move2board_sep = "\n";
const move2board_sep4output = "\n\n";
const re = new RegExp(
"(" +
board_pat +
")" +
board2move_sep +
"(" +
move_line_pat +
")" +
"\\n" +
move2board_sep +
"(?=" +
"(" +
board_pat +
")" +
")",
"gms",
);
let expanded_sol = initial_str;
let changes = 0;
do {
changes = 0;
expanded_sol = expanded_sol.replace(
new RegExp(
"(" +
board_pat +
")" +
board2move_sep +
"(" +
move_line_pat +
")" +
"\\n" +
move2board_sep +
"(?=" +
"(" +
board_pat +
")" +
")",
"gms",
),
re,
function replacer(match, initial_str, move, fin) {
++changes;
let ret = "";
Expand Down

0 comments on commit e57a33f

Please sign in to comment.