I have a string that contains both individual numbers (can be single digit, can be multiple as well) and numbers with square brackets around them like [4]
I am using regular expressions and trying to remove all occurrences of the numbers with the square brackets, leaving regular numbers alone.
E.g, if the string was 32 02 53 [1] [2] [33], the result should be 32 02 53.
The current code I use is:
$data = preg_replace('#[(\d+)]#', '', $data);
But this replaces/removes all numbers and leaves the brackets.
Try this:
Because with unescaped brackets it means: a group of one or more digits.