1

Topic: Repeated characters in one

There are lines where for various reasons there is a repetition of characters, for example successively 10 gaps, or 28 commas or how many other characters. And from all this train successively going characters for each character it is necessary to leave one - one gap from 10, one comma from 28 etc., etc. Certainly can be removed , but whether is interesting probably to make , RegExp'? Prompt expression with .
Example of a line

 PARCHMENT ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 50//////2, - 470-81. . ON 14, WEIGHT OF UNDERPANS 322. 

It is necessary to leave

 PARCHMENT VEGETATIVE, OPAQUE, MASS 50GR/M2, - 470-81. . ON 14, WEIGHT OF UNDERPANS 322. 

2

Re: Repeated characters in one

Whether

mds_world wrote:

probably to make , RegExp'?

Something like the such

Sub Test1 ()
Dim oRegExp As Object
Dim str1 As String
str1 = "PARCHMENT ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 50//////2, - 470-81. . ON 14, WEIGHT OF UNDERPANS 322."
Set oRegExp = CreateObject ("VBScript. RegExp")
oRegExp. Global = True
oRegExp. Pattern = "(.) \1 +"
Debug. Print str1
Debug. Print oRegExp. Replace (str1, "$1")
Set oRegExp = Nothing
End Sub
Test1
PARCHMENT ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 50//////2, - 470-81. . ON 14, WEIGHT OF UNDERPANS 322.
PARCHMENT VEGETATIVE, OPAQUE,  50GR/M2, - 470-81. . ON 14, WEIGHT  32.

3

Re: Repeated characters in one

RegExp, wrote:

Test1
PARCHMENT ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,>>><<< 50//////2, - 470-81. . ON 14, WEIGHT>>> UNDERPANS <<<322.
PARCHMENT VEGETATIVE, OPAQUE,>>>  <<<50GR/M2, - 470-81. . ON 14, WEIGHT>>>  <<<32.

smile))
Litter, only "reached" that "not all so is unambiguous" smile
So,

Sub Test1 ()
Dim oRegExp As Object
Dim str1 As String
str1 = "PARCHMENT ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 50//////2, - 470-81. . ON 14, WEIGHT OF UNDERPANS 322."
Set oRegExp = CreateObject ("VBScript. RegExp")
oRegExp. Global = True
==> oRegExp. Pattern = "([^-0-9]) \1 +"
Debug. Print str1
Debug. Print oRegExp. Replace (str1, "$1")
Set oRegExp = Nothing
End Sub
Test1
PARCHMENT ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 50//////2, - 470-81. . ON 14, WEIGHT OF UNDERPANS 322.
PARCHMENT VEGETATIVE, OPAQUE, MASS 50GR/M2, - 470-81. . ON 14, WEIGHT OF UNDERPANS 322.

4

Re: Repeated characters in one

I would advise to specify, on the contrary, in  symbol set which it is necessary "". For that any character is not cleaned to see and add in the code easier, than to note erratic removal of characters.

5

Re: Repeated characters in one

Akina wrote:

I would advise to specify, on the contrary, in  symbol set which it is necessary "". For that any character is not cleaned to see and add in the code easier, than to note erratic removal of characters.

+1

oRegExp. Pattern = "([,/]) \1 +"

6

Re: Repeated characters in one

Thanks! All turned out