Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Need a GREP help

Explorer ,
Sep 17, 2021 Sep 17, 2021

I want to replace Double character to single character 

Example

AA to A

BB to B

CC to C

DD to D

GG to G

 

So I use the parenthesis to find the character by group like (AA)|(BB)|(CC)|(DD)|(GG)

 

What i need to mention as a Change.

 

I tried with A$1,B$2,C$3,D$4

But is not working, I can undestand my method is wrong.

 

help me to find the right solution 

 

 

Thankyou

TOPICS
Print , Scripting
600
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 4 Correct answers

Community Expert , Sep 17, 2021 Sep 17, 2021

Try using:

(\w)\1

for your grep pattern. The trailing \1 is a back reference to the character captured in group 1 (in parentheses) so it matches two of the same character.

In your changeTo you can use $1 to refer to that same character.

Translate
Community Expert , Sep 17, 2021 Sep 17, 2021

Find: (\u)\1
Change: $1

Translate
Community Expert , Sep 17, 2021 Sep 17, 2021

You already have two correct answers, and here's another approach. A bit different, in theory a bit more efficient:

 

Find: (\w)(?=\1)

Replace: <leave blank>

 

It deletes a word character only if it's followed by its duplicate.

Translate
Community Expert , Sep 17, 2021 Sep 17, 2021

And here a forth and fifth ways to do it...

Find: (\u)\K\1
Replace: <leave blank>

Find: (?<=(\u))\1
Replace: <leave blank>

Translate
Community Expert ,
Sep 17, 2021 Sep 17, 2021

Try using:

(\w)\1

for your grep pattern. The trailing \1 is a back reference to the character captured in group 1 (in parentheses) so it matches two of the same character.

In your changeTo you can use $1 to refer to that same character.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 17, 2021 Sep 17, 2021

Find: (\u)\1
Change: $1

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 17, 2021 Sep 17, 2021

You already have two correct answers, and here's another approach. A bit different, in theory a bit more efficient:

 

Find: (\w)(?=\1)

Replace: <leave blank>

 

It deletes a word character only if it's followed by its duplicate.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 17, 2021 Sep 17, 2021

And here a forth and fifth ways to do it...

Find: (\u)\K\1
Replace: <leave blank>

Find: (?<=(\u))\1
Replace: <leave blank>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 17, 2021 Sep 17, 2021

Spoilt for choice!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 19, 2021 Sep 19, 2021
LATEST

Thankyou all for the right Answer.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines