Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #450 #456

Merged
merged 2 commits into from
May 23, 2024
Merged

Issue #450 #456

merged 2 commits into from
May 23, 2024

Conversation

MahmoudRH
Copy link
Contributor

This pull request fixes issue #450

Explaination:

  • text to be formatted: "5,000 + 50,0000"
  • textNoSeparators: "5000 + 500000"
  • extractedNumbers: [5000,500000]
  • numbersWithSeparators: ["5,000" , "500,000"]

the issue happens here: [during the loop of replacing the nubmers with the formatted numbers]
numbersList.forEachIndexed { index, number ->
textWithSeparators = textWithSeparators.replace(number, numbersWithSeparators[index])
}
in the first loop [index: 0, number: 5000]
replace will find two places for '5000' in the expression like this "[5000] + [5000]00"
so , textWithSeparators will be "[5,000] + [5,000]00"

using replaceFirst fixes the issue as it only replaces the first occurrence of the number

@Darkempire78 Darkempire78 merged commit af139d6 into Darkempire78:main May 23, 2024
2 checks passed
@Darkempire78
Copy link
Owner

thank you so much! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants