I really am not getting how I can match just a single instance of both a whitespace or a dash. I am able to get some results but still unable to get the desired one. I have actually tried different configurations from regexr.com and what not but still cant get it to work.[regex padawan here]
Shell: Powershell
Data : "test--asd :45; wth---notcool: 69"
Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Value t e s t - - a s d : 4 5 ; w t h - - - n o t c o o l : 6 9
Test 1 regex = '([\s\-])\1?'
Test 2 regex = '([\s\-]){1}'
Testing 1 Testing 2 Desired to be REMOVED
Index Value Index Value Index Value
----- ----- ----- ----- ----- -----
4 -- 4 - 5 -
9 5 - 9
14 9 14
18 -- 14 19 -
20 - 18 - 20 -
29 19 - 30
20 -
29
30
I think im missing something really basic here or fundamental, but my main goal with this is that I want to use regex to basically reduce the spaces and dashes to a single instance each so that the string isn't messy.
******* EDIT (Added explanation) *******
Basically, what I need to do is to get rid of the white-spaces and to transform the redundant dashes to a single dash. This is why I thought I could create a regex to select(get the index) the white-spaces and the extra dashes(starting from the 2nd consecutive dash) and replace them as nothing(''). Sorry for the confusion, having a difficulty in stating the issue and the correct approach.
So the main goal is reflected below, I jsut need to get rid of the ones in yellow: