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

Can I use GREP to find and replace 01 02 03 with 1 2 3?

Participant ,
Jan 27, 2017 Jan 27, 2017

Copy link to clipboard

Copied

Hi

Can anyone provide me with the GREP search string that will allow me to quickly find and replace instances of numbers, 01 02 03 04 05 06 07 08 09 with 1 2 3 4 5 6 7 8 9?

Thanks, much appreciated.

Alex

Views

692

Translate

Translate

Report

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 1 Correct answer

Community Expert , Jan 27, 2017 Jan 27, 2017

Find

\<(0)(\d)

Replace

$2

This will find any zero followed by any digit at the start of a "word", and replace it with only the digit that follows. It leaves alone any zero in other locations (so a number like 408 or 480 would not be affected)

Votes

Translate

Translate
Community Expert ,
Jan 27, 2017 Jan 27, 2017

Copy link to clipboard

Copied

Find

\<(0)(\d)

Replace

$2

This will find any zero followed by any digit at the start of a "word", and replace it with only the digit that follows. It leaves alone any zero in other locations (so a number like 408 or 480 would not be affected)

Votes

Translate

Translate

Report

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
Participant ,
Jan 27, 2017 Jan 27, 2017

Copy link to clipboard

Copied

Eureka! this is fantastic, beautiful even. Thanks so much.

Votes

Translate

Translate

Report

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
Guide ,
Jan 27, 2017 Jan 27, 2017

Copy link to clipboard

Copied

Yep, but...

[mode nitpick ON]

numbers like 024 or 0357 would also be affected. And so would be 00...

If I read carefully the request, only 01 to 09 should be grabbed.

So... maybe

Find \<(0)([1-9](?!\d))

Replace $2

[mode nitpick OFF]

Votes

Translate

Translate

Report

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
Participant ,
Jan 27, 2017 Jan 27, 2017

Copy link to clipboard

Copied

[mode bliss ON]

Votes

Translate

Translate

Report

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 ,
Jan 27, 2017 Jan 27, 2017

Copy link to clipboard

Copied

Good point, vinny

I made the (perhaps faulty) assumption that all numbers with leading zeros were to be fixed ( and the double-zero situation didn't occur to me).

Votes

Translate

Translate

Report

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
LEGEND ,
Jan 27, 2017 Jan 27, 2017

Copy link to clipboard

Copied

LATEST

Good enough! …

Capture d’écran 2017-01-27 à 16.50.14.png

(^/)

Votes

Translate

Translate

Report

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