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

Grep Style to eliminate second decimal place.

Community Beginner ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

I was given an excel sheet to format, and now the client has asked me to eliminate the second decimal number (ex change 10.70% -> 10.7%) I wanted to know if someone knew how to specifically target that second number via grep styles or Find/replace. Thanks is advanced, this would help immensely.

Screen Shot 2024-03-13 at 5.07.16 PM.png

TOPICS
How to

Views

356

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 , Mar 13, 2024 Mar 13, 2024

You cannot use GREP Styles to remove content. For that you must use GREP in Find/Change.

Screenshot 2024-03-13 at 4.13.29 PM.png

 

Find: \.(\d)\d%

Change: .$1%

Votes

Translate

Translate
Community Expert ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

You cannot use GREP Styles to remove content. For that you must use GREP in Find/Change.

Screenshot 2024-03-13 at 4.13.29 PM.png

 

Find: \.(\d)\d%

Change: .$1%

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 ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

quote

You cannot use GREP Styles to remove content.

 

By @Scott Falkner

 

You can't "remove" - but you can "hide"...

 

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 ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

quote

 

You can't "remove" - but you can "hide"...

 


By @Robert at ID-Tasker


True. You could use the Find expression in a GREP Style and apply a character style that uses a very small point size plus a very small scale percentage, which would effectively make the characters disappear. 0.1 point, with 1% horizontal scale and no fill colour would do the trick.

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 Beginner ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

Thanks Scott! That was perfect! (and stopped me from manually deleting 300 zeros)

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 ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

@Brandon32002375r2v2 

 

Looks like you ALWAYS have "0%"? Why not replace "0%" with "%"?

 

Or go with @Scott Falkner's much more universal approach.

 

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 ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

My method will only remove the final digit before the %, it will not round. Rounding would require a more complicated expression at best and more likely is not possible. I mean, you could probably write an expression smart enough to round 12.87% up to 12.9% but rounding 19.97% up to 20.0% seems non-doable.

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 ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

@Scott Falkner 

 

Something like this?

 

RobertTkaczyk_7-1710378171644.png

 

"19.97% up to 20.0%" - only scripting or few separate GREPs - depends on how much you want to round up - only 19.xx -> 20.00 or 15.xx-19.xx -> 20.00

 

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 ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

 

@Scott Falkner 

 

Or rather this?

 

RobertTkaczyk_0-1710378410898.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
Community Expert ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

It would have to round every possibility. X.0(5-9) to X.1, X.1(5-9) to X.2, X.2(5-9) to X.3, X.3(5-9) to X.4, etc. Then repeat for every possibiliy of X.9(5-9) to X+1.0.

 

Now add for every X9.0(5-9) to [X=1]0.0 (e.g. 29.96 rounds to 30.0). Even if you did plug in all those GREP expressions I bet the document would run like molasses in January.

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 ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

quote

It would have to round every possibility. X.0(5-9) to X.1, X.1(5-9) to X.2, X.2(5-9) to X.3, X.3(5-9) to X.4, etc. Then repeat for every possibiliy of X.9(5-9) to X+1.0.

 

Now add for every X9.0(5-9) to [X=1]0.0 (e.g. 29.96 rounds to 30.0). Even if you did plug in all those GREP expressions I bet the document would run like molasses in January.


By @Scott Falkner

 

If you want to round up to whole numbers - then yes, it's pointless.

 

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 Beginner ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

LATEST

In hindsight you're right. Though I have a feeling that future data sheets aren't going to be as clean, so it's good to know it's possible 🙂 Thanks for the solution though! 

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 ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

If it's just every similar thing like 10.70% -> 10.7%

where the 0 is removed 


Find

\.\d\K0(?=%)

Change to

<leave blank>

 

 

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