Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

recommendation on removing unused characters #8

Copy link
Copy link
@mesqueeb

Description

@mesqueeb
Issue body actions

we use this with text field user input.

if the user ends its string in any of these ways:

  • 100 + 100 +
  • 100.1 + 100.
  • 100 + 100 =
  • 1,000 + 1,000

we want it to still work, so we have to manually remove (1) any non math characters like (, separators) and any trailing math characters at the end like ., +, = etc.

Currently we wrote a regex that cleans up the user input before piping it through the string-math like so:

calculatorInput
      .replaceAll(/[^.0-9\-+*/^e()]/g, '')
      .replace(/[^0-9()]$/, '')

is there any advice you can give if this is a good way to do it?

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.