-2

I want to delete all characters after the "[" character like the screenshot below:

Schreenshot

How do I achieve this?

2 Answers2

0

Input examples from the provided screenshot:

  • 189 [122-270]
  • 18 [5.10-6.90]

The easiest way would be to split the column on the separator [ and delete the second column.

The more elaborate way would be to use a regular expression:

value.replace(/\s\[[^\]]+\]/, "")

Play around with https://regex101.com/ or https://regexr.com/ to find out more about how this regular expression works.

b2m
  • 529
  • 3
  • 11
0

if you want to skip regex complexity, I will use the split function value.split('[')[0] The split() function create an array, and the [0] selector pick the first value of the array.

magdmartin
  • 1,712
  • 3
  • 20
  • 43