Removing extra spaces from a long document

Hello
I have seen a number of find/change and GREP formulas to do similar things. I have NO scripting or coding experience and have labored to understand GREP.
So I am a little afraid to use it as I don't know what all the modifiers refer to (I do have a printout of some neat GREP cheatsheets like Mike Witherell's that I can absorb until I obtain a good reference )
I need something I can copy and paste into either find/change or GREP dialog that will do the following in less than 12 steps (hopefully) without doing something catastrophic like removing all of my paragraph marks (which I almost did using someones GREP expression)
No spaces before any comma, period, exclamation mark, question mark, colon, semicolon
One space only after any of those
One Space before any opening parenthesis and one space after the closing parenthesis
No space after the opening parenthesis or before the closing parenthesis
Remove any double or extra spaces ( en, em etc.)
Remove any commas before parentheses
Remove any spaces after a paragraph mark
I think that's it
I did find this one recently (Maybe Jongware?)
[~m~>~f~|~S~s<~/~,~3~4%]{2
Which from my dim understanding addresses em, en, flush and hair space ,  nonbreaking space ,figure space,third space--not sure of the rest. Really this is way over my head.
I know this will be a piece of cake for you guys
Thanks

A: Removing extra spaces from a long document

Peter is too modest, he's doing just great.
No space BEFORE-One Space after ---period,semicolon,colon, exclamation, question mark,CLOSING Parenth,Bracket,Brace, single & Dbl. quotation marks
Find (\s)([.,;:!\)\]\}~}~]])
Replace with $2
No space AFTER-One Space Before----OPENING bracket,brace,parenthesis,Dbl & single quotes
Find ([\[\{\(~{~[])(\s)
Replace with $1
These remove the space before/after but do not automatically add a space after/before.
In the first case, you could add a space right after the '$2' in the Replace With string, but it already may have a space, in which case you suddenly have two. One alternative is to optionally remove it with the Find string (add it as an optional match) and always add it with the Replace string, but remember that this string will only be found if there is a space preceding it. That way you'd only check the space after in cases where there was a bad space before.
So I propose you add another two find/changes to add the space, only when necessary.
One Space After: find
([.,;:!\)\]\}~}~]])(?!\s)
replace:
$0 [followed by one single space]
One Space Before: find
(?<!\s)([\[\{\(~{~[])
replace:
[one single space] $0
Color-coding with my WhatTheGrep might make it just a tad clearer what's going on in that jumble of codes:
(1 [ .,;:! \) \] \} ~} ~] ] 1) (?!! \s !)
and
(?<!<! \s <!) (1 [ \[ \{ \( ~{ ~[ ] 1)
(Orange is lookahead/lookbehind, blue is a regular escaped character, pink is an InDesign special character, green is normal grouping parentheses, and lavender is a character group.)

Peter is too modest, he's doing just great.
No space BEFORE-One Space after ---period,semicolon,colon, exclamation, question mark,CLOSING Parenth,Bracket,Brace, single & Dbl. quotation marks
Find (\s)([.,;:!\)\]\}~}~]])
Replace with $2
No space AFTER-One Space Before----OPENING bracket,brace,parenthesis,Dbl & single quotes
Find ([\[\{\(~{~[])(\s)
Replace with $1
These remove the space before/after but do not automatically add a space after/before.
In the first case, you could add a space right after the '$2' in the Replace With string, but it already may have a space, in which case you suddenly have two. One alternative is to optionally remove it with the Find string (add it as an optional match) and always add it with the Replace string, but remember that this string will only be found if there is a space preceding it. That way you'd only check the space after in cases where there was a bad space before.
So I propose you add another two find/changes to add the space, only when necessary.
One Space After: find
([.,;:!\)\]\}~}~]])(?!\s)
replace:
$0 [followed by one single space]
One Space Before: find
(?<!\s)([\[\{\(~{~[])
replace:
[one single space] $0
Color-coding with my WhatTheGrep might make it just a tad clearer what's going on in that jumble of codes:
(1 [ .,;:! \) \] \} ~} ~] ] 1) (?!! \s !)
and
(?<!<! \s <!) (1 [ \[ \{ \( ~{ ~[ ] 1)
(Orange is lookahead/lookbehind, blue is a regular escaped character, pink is an InDesign special character, green is normal grouping parentheses, and lavender is a character group.)

Similar Messages

  • How to remove extra spaces from Data Matrix Label?

    Hi All,
    Kindly let me know how we can remove extra spaces from Data Matrix Label.
    Suppose we have this following code in SO10.
    ^FO1380,1879^COY,78^BY4^BXR,6,200^FH^FD[)>_1E06_1DF01001T_1D6JUN&v_huf&&v_hul&_1DV&v_supnum1&_1D16K&v_del&_1D6D&v_flddat1&095_1D2L&v_unload&_1D
    P&v_article&_1D4L&v_madein&_1D_1E_04^FS.
    Variable have there own value. and the desired result will be shown like the attachment.
    But in my code it splits into new line when CMIR value has 3 spaces.
    If CMIR value is 1S0 820 355 A . then it creats a new line.
    Kindly suggest me any possible solution.
    Thanks,
    Partha

    Hi Gaurav,
    In print preview we can't see any space or new line. But when it scanned by TSB (barcode scanner) it will generate a new line when there is 3 space CMIR value.
    So where should I write SHIFT CMIR LEFT DELETING LEADING space this code?
    Because there is no space coming at the time of debugging or print preview.
    And in SO10 the code written as
    ^FO1380,1879^BY4^BXR,6,200^FH^FD[)>
    Here CMIR value is 1SO 820 303 A
    and generated output is like this.
    And desired output should be like this.

  • Why can I not remove extra spaces from Mail when composing?

    I am using Mail Version 8.1 and I cannot find a way to remove extra spaces from between my lines while composing. Every Enter makes the cursor go down two lines and there is no way to type in the space in between. There seems to be now way to see the html or any tags that can be causing this, and I cannot seem to find any setting to change the line spacing either. Does anyone know where to find any of these options so I can simply make the text single space?

    Open a message-editing window. Under the Edit menu, deselect all the options in the Spelling and Substitutions sub-menus. Test.

  • Removing extra spaces from email attachment of text file

    Hi All,
    I am having a question in opening email attachment file in text mode.
    Whenever I am trying to open a CSV file in text mode after each row it adds blank spaces. These blank spaces are to complete the 255 characters on each row I guess.
    My client doesn't want these space. So can anybody tell how to remove those spaces?
    <removed by moderator> response would be helpful.
    Thanks and Regards
    Nishad
    Edited by: Thomas Zloch on Apr 28, 2011 4:02 PM - priority normalized

    Hi,
    There is no solution for this as u know that the data which you r sending in csv its actually getting populated from an internal table.
    You cannot make your internel table dynamic for this requirment.
    It should have a fixed length. Now if the data is less then also the length.
    So u have identified correct that because of 255 the blank space is population, nothing is in your hand.
    U have to convince the client, to make them understand where is the limitation.
    Thanks & Regards
    Prasenjit

  • Remove extra space

    Hi master,
    how to remove extra space from the tables and columns
    thanks

    Apparently table and/or column names that have been created don't match those being used in queries.
    This typically happens when you use tools that generate scripts with object (table/column) names in "double-quotes" thus causing them to be CaSe-SeNsItIvE to Oracle.
    See this short demo of sensitive object names :
    SQL> create table "My Table"  (col_1 varchar2(5));  -- Sensitive Name used
    Table created.
    SQL> desc my table 
    Usage: DESCRIBE [schema.]object[@db_link]  -- cannot find an object by the name "my table"
    SQL> desc "My Table"  -- I must explicitly use the Sensitive Name now !!!!
    Name                                                                     Null?    Type
    COL_1                                                                             VARCHAR2(5)
    SQL> desc "MY TABLE"  -- The name does not map across CASE either !
    ERROR:
    ORA-04043: object "MY TABLE" does not exist
    SQL> create table MY TABLE (col_1 varchar2(15));  -- Normally, object names cannot contain spaces !
    create table MY TABLE (col_1 varchar2(15))
    ERROR at line 1:
    ORA-00922: missing or invalid option
    SQL> create table MY_TABLE (col_1 varchar2(15));  --- this is the correct way to name an object.  DON'T USE "double-quotes" ; DON'T USE SPACEs
    Table created.
    SQL> desc MY_TABLE  -- the properly named
    Name                                                                     Null?    Type
    COL_1                                                                             VARCHAR2(15)
    SQL> desc "My Table"  -- the first , Sensitive name
    Name                                                                     Null?    Type
    COL_1                                                                             VARCHAR2(5)
    SQL>Hemant K Chitale
    http://hemantoracledba.blogspot.com

  • How to remove extra spaces in a xml formatted string

    Hi,
    I am trying to remove extra spaces between the xml tags. For
    example, if a string is something like
    ' <header 1> <header 2> test </header 2> </header1>'
    I want to get rid of the spaces only between the closing tag of header 1 and opening tag of header 2 and closing tag of header 2 and opening tag of header 1, in short ,I want to remove the extra spaces between the tags if there are no other characters between them. I do not want the remove the spaces between closing tag header 2 and opening tag of header ,as there is occurence of other characters.
    I am aware that this can be done by looping through the string and using instr to identify the characters '<' and '>', but I would like to use it as a last resort only.
    Can anyone suggest me a better way of doing it in a single go by manipulating the data?
    Any help is really appreciated.
    Regards,
    Anil.

    You can use the replace function. If you only expect one extra space, then:
    scott@ORA92> select replace ('<header 1> <header 2> test </header 2> </header1>',
    2      '><', '><')
    3 from dual
    4 /
    REPLACE('<HEADER1><HEADER2>TEST</HEADER2></HEADER
    <header 1> <header 2> test </header 2> </header1>
    If you expect more extra spaces, then you will need to wrap another replace function around it for each space, for example the following will eliminate up to three spaces:
    scott@ORA92> select replace (replace (replace ('<header 1> <header 2> test </header 2> </header1>',
    2      '>     <', '><'), '>     <', '><'), '> <', '><')
    3 from dual
    4 /
    REPLACE(REPLACE(REPLACE('<HEADER1><HEADER2>TEST
    <header 1><header 2> test </header 2></header1>

  • How do I remove extra profiles from color mangement in Print Module?

    How do I remove extra profiles from color mangement in Print Module?

    If you're talking about the "short list" then click on other and then uncheck the ones that you don't want displayed. If you're talking about the long list, then you will have to browse to the folder containing the profiles and then delete them manually.

  • How can I remove a page from a PDF document and save it as a new PDF document?

    How can I remove a page from a PDF document and save it as a new PDF document?

    Tools - Pages - Extract and tick the option to delete the extracted page from the original file.

  • How to find the extra spaces from personal computer?

    I cannot update Adobe new items since the box window told me that there were no spaces from my computer. Who can teach me how to find the extra spaces from my computer? Besides, there are 1/3 spaces for IOS, 1/3 spaces for virtual computer and 1/3 spaces for Adobe in my computer. No any photos and movies  in my computer now.

    I do not understand the question... what do you mean by spaces?
    What size is your hard drive, and what does your system tell you about unused hard drive space?

  • How do you remove the extra space from the top margin when printing from a website? Already reset Firefox and checked my settings. Using Firefox 18 & Windows 8

    I have a 2" space at the top of pages that I print from websites. How do I remove the extra space? My margin settings are at .5"

    laderamacguy took a look at it and added a black shape over the tab. he suggested i use a different template next time, such as the black template.

  • How do I remove extra space after an image in an ePub created with InDesign?

    I've designed more than a dozen ebooks with InDesign and have recently been having problems with the spacing after images, both images that are anchored in the text or stand-alone and exported through the Articles Panel. Following are a few details:
    • In the Object Export Settings, I have the vertical spacing set to 0 both before and after the images and no breaks added.
    • In the Export panel, I do not have any vertical spacing applied to images.
    • I do not have any Object Style settings applied.
    • It doesn't seem to matter if I anchor the image into the text or have it as a stand-alone image in the Articles Panel with the caption after it in a separate text box, also in the Articles Panel.
    • I broke down the ePub into an html file and did not see any div or span classes that were different between images that are showing correctly vs. incorrectly.
    • Extra space appears in both iBooks on my computer, as well as on my iPad.
    • I converted to a mobi file for the Kindle and the space wasn't there.
    See attached screen shot. There shouldn't be that big gap between the image and the orange caption.
    Any help or suggestions anyone can provide would be greatly appreciated. I feel like I've tried everything I can think of with the same results over and over!

    Yes. That is the technique I traditionally use to drop an image into text. I even cut and pasted again as you suggested with the same result. Trust me, this is driving me nuts. I'm not doing anything different than before, but my results are different, even within the same document. I'll attach a few examples, all from this same document.
    How the space after my in-line image is supposed to look:
    And then a few of the pages with the mystery gap:

  • How do i remove extra space in word program?

    Recently I have typed typed an apostrophe in word program & it adds an extra space.  How do i get rid of that?  I have tried everything.  It is everytime I type a word with an apostrophe  Thank you

    Yes. That is the technique I traditionally use to drop an image into text. I even cut and pasted again as you suggested with the same result. Trust me, this is driving me nuts. I'm not doing anything different than before, but my results are different, even within the same document. I'll attach a few examples, all from this same document.
    How the space after my in-line image is supposed to look:
    And then a few of the pages with the mystery gap:

  • Remove extra space value of the field  in text element

    Dear All,
    Can any one please help me out to remove the blank spaces in the text elements of SF.
    we are printing Label in which i want print  quantity of material. and i am using MSEG-MENGE for quantity of maetrial.
    But the issues is when we are printing the label. We are getting spaces  in the Text elements fields &MSEG-MENGE&.
    i am also check menge field within mseg table. in which menge field define as QUAN data type with length 13.
    <
    MAT CODE:&t_MSEG-MATNR&
    DESC:&MAKTX&
    QTY:&t_MSEG-MENGE&          
    UOM:&t_MSEG-MEINS&
    >
    My Output in SF:
    MAT CODE:11000002
    DESC:Coarse Aggregate 10mm Sieve
    QTY:             960
    UOM:LBM
    MIGO.NO.:4900000025
    how to remove extra blank spaces in the text elements ( QTY:             960 )
    guide me.........

    Dear All,
    I am using  code block in SF before text element.
    In  The Text Element ...
    <
    MAT CODE:&t_MSEG-MATNR&
    DESC:&MAKTX&
    QTY:&t_MSEG-MENGE&
    UOM:&t_MSEG-MEINS&
    MIGO.NO.:&t_MSEG-MBLNR&
    PO.NO.:&t_MSEG-EBELN&
    LOCATION:&t_MSEG-WERK&&NAME1&
    >
    In programe Line ( code block )....
    <
    read table t_mseg index w_index.
    qty = t_mseg-menge.
    condense qty.
    SELECT SINGLE name1 FROM t001w INTO name1 WHERE werks = t_mseg-werks.
    SELECT SINGLE maktx FROM makt INTO maktx WHERE matnr = t_mseg-matnr.
    >
    My Output:
    MAT CODE:11000002
    DESC:Coarse Aggregate 10mm Sieve
    QTY:                                                      960
    UOM:LBM
    MIGO.NO.:4900000025
    Only problem in value of Quantity field .
    guide me.........

  • Remove Extra Space into internal buttons of ToggleButtonBar ( mx )

    Hi all,
    I am stuck with some spacing issue. I use a toggle button bar and need buttons to be as tight as possible while displaying label without breaking it.
    Eventually, the toggleButtonBar must appear as :
    en fr de
    Spacing between labels is quite what I expect to be in the final app. BUT if I dramaticcaly reduce button size, the label is cropped because buttons keep extra spacing around label. How can I reduce this space to 0 per say ?
    I can't see any way to do it.
    TIA
    Loic

    Yes. That is the technique I traditionally use to drop an image into text. I even cut and pasted again as you suggested with the same result. Trust me, this is driving me nuts. I'm not doing anything different than before, but my results are different, even within the same document. I'll attach a few examples, all from this same document.
    How the space after my in-line image is supposed to look:
    And then a few of the pages with the mystery gap:

  • IDCS5-JS:Remove extra space in equation

    How to remove around space [extra space] in equations eps file generated from Mathtype when placing it in InDesign.
    Any suggestions....

    Hello
    The simplest way is...
    Open Windows registry, find key
    HKEY_CURRENT_USER\Software\Design Science\DSMT6\Windows
    Now you can change
    PicturePadding
    The default is 2 (possible points, but I don't sure), but you can change it (0 - to delete all paddings).
    BUTdon't forget to process all your equations (after PicturePadding was changed) in Word (by Format) or in InDesign (by Batch convertion... - it's possible if you use MT-Script for InDesign (www.mtscript.ru))
    And only after that you will see equations without paddings.
    Thank you.

Maybe you are looking for

  • Webutil_c_api char error

    I'm trying to execute the following C function: extern "C" PRUEBADLL_API int fnPruebaDLL(char* value); This function shows a simple Dialog. Firtsly I executed the function: extern "C" PRUEBADLL_API int fnPruebaDLL(); And it was ok. But with the param

  • I have a folder yahoo conversation that opens and won't let me open anything else. I do not even have a yahoo account

    A folder Y conversation showed up under each account.I right clicked on it and selected delete. It won't delete.It is now open and won't close. When I exit out Thunderbird closes.When I reopen thunderbird that file opens.

  • Can't Delete Events or Calendars

    Hello, I have a very modest iCal setup, 3 calendars, syncs only to my personal iPhone, no MobileMe backup. Today I copied an event to the clipboard and pasted it in somewhere else. That led quickly to a situation where new events and calendars could

  • Cannot record guitar properly!

    I am fairly new to Garage Band. I just bought iMic and an adaptor and I plugged my guitar pickup in it. It's a Shadow external pickup that is supposedly of good quality but obviously isn't as good as an internal pickup. When I record my guitar on Gar

  • Reg:Receiver FCC

    Hi ..    Can you plese help in writing the Conversion Parameters for the below structure.. <?xml version="1.0" encoding="UTF-8"?> <ns0:MT_FCC xmlns:ns0="http://krft.com/FCC">    <Header>       <Name/>       <No/>       <Location/>    </Header>    <Da