REMOVEREPEATS

=REMOVEREPEATS(array,repeatChar)

array
is a 1D array of values
repeatChar
is a single value to remove from the array if repeated

REMOVEREPEATS removes chosen repeated characters from an array.

RicoS

Board Regular
Joined
May 1, 2019
Messages
62
REMOVEREPEATS removes chosen repeated characters from an array

Excel Formula:
=LAMBDA(array,repeatChar,
   LET(a,array,rpt,repeatChar,
      ttaA,TEXTTOARRAY(a),
      isMatch,--(ttaA=rpt),
      cA,COLUMNS(ttaA),
      rArr,RESIZEARRAY(RIGHTARRAY(isMatch,cA-1,0),,cA,0),
      isRepeat,1-(isMatch*rArr=1),
      rptCols,COLUMNNUMBERS(isRepeat)*isRepeat,
      srtRows,SORTROWS(rptCols,1),
      idx,IF(srtRows=0,"",INDEX(ttaA,ROWNUMBERS(srtRows),srtRows)),
      return,TEXTJOINARRAY(idx,,),
   return)
)

Lambda - Last Cell and Split.xlsx
B
1Original Array
2test--this--removal--of---repeats
3this--test--is---the-greatest---test--you'll--ever--see
4further--test--to---prove-----that--I'm--serious
5
6
7Text join
8test-this-removal-of-repeats
9this-test-is-the-greatest-test-you'll-ever-see
10further-test-to-prove-that-I'm-serious
Sheet1
Cell Formulas
RangeFormula
B8:B10B8=REMOVEREPEATS(B2:B4,"-")
Dynamic array formulas.
 
Upvote 0
Alternatively, by using TRIM: (I learned that Excel TRIM function removes extra spaces from @MrExcel for the first time in my life after creating SLUGIFY and SLUGIFY.PLUS functions)

Lambda.xlsm
BC
1Original Array
2test--this--removal--of---repeats
3this--test--is---the-greatest---test--you'll--ever--see
4further--test--to---prove-----that--I'm--serious
5
6
7SUBSTITUTE & TRIMAlso using LET to pass the delimiter once
8test-this-removal-of-repeatstest-this-removal-of-repeats
9this-test-is-the-greatest-test-you'll-ever-seethis-test-is-the-greatest-test-you'll-ever-see
10further-test-to-prove-that-I'm-seriousfurther-test-to-prove-that-I'm-serious
Sheet4
Cell Formulas
RangeFormula
B8:B10B8=SUBSTITUTE(TRIM(SUBSTITUTE(B2:B4,"-"," "))," ", "-")
C8:C10C8=LET(delim,"-",SUBSTITUTE(TRIM(SUBSTITUTE(B2:B4,delim," "))," ",delim))
Dynamic array formulas.
 
Alternatively, by using TRIM: (I learned that Excel TRIM function removes extra spaces from @MrExcel for the first time in my life after creating SLUGIFY and SLUGIFY.PLUS functions)

That's definitely superior! To be honest, I just needed something to use up all these LAMBDAs I've been creating. I have been using them a lot in other things too. I think the good thing to take out of these posts (for me anyway) is that others may (or may not) find the actual function of the functions useful. I don't expect my solutions to be the most optimal, but I've found a need for the basic ones like ROWNUMBERS() and so on for quite a few things, so hopefully others will too (and improve on them!).
 
That's definitely superior!
I felt exactly the same when Bill showed me how TRIM removes the extra spaces right after I posted the SLUGIFY.PLUS that basically extends SLUGIFY to do what TRIM can do easily :). Or Peter showed me that I don't need an array formula in the REVERSE function. This is all great!

And it is great what we are doing with Lambda samples. We are finding new ways and trying to learn/discover Lambda's capabilities, discussing the functions. I am sure these samples will also help the Lambda developer team to extend the function with new features.
 

Forum statistics

Threads
1,223,574
Messages
6,173,146
Members
452,502
Latest member
PQCurious

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top