export function reverseToRtl(text) {
  const regex = /(\d+(\.\d+)?)/g;
  var reversedDecimal = "";
  reversedDecimal = text.replace(regex, (match) => {
    if (match.includes(".")) {
      const [integerPart, decimalPart] = match.split(".");
      return (
        decimalPart.split("").reverse().join("") +
        "." +
        integerPart.split("").reverse().join("")
      );
    } else {
      return match.split("").reverse().join("");
    }
  });

  const datePattern = /\d{4}\/\d{2}\/\d{2}/g;

  const finaltext = reversedDecimal.replace(datePattern, (match) => {
    const parts = match.split("/");
    if (parts.length === 3) {
      const [year, month, day] = parts;
      return `${day}/${month}/${year}`;
    } else {
      return match;
    }
  });

  return finaltext;
}
