Eliminating Parentheses and Words Between Them In Word Doc

Discussion in 'Computer Support' started by Martin, Jul 12, 2007.

  1. Martin

    Martin Guest

    Hello,

    I am trying to create a Word doc that lists every town in New York State,
    but excludes the county in which the town is located.

    If it's relevant, my information comes from the U.S. Census.

    For instance, the town of Adams is in Jefferson County. The format that I'm
    accessing is as follows: Adams (Jefferson County).

    What I would like to do is use the find or replace function in Word 2002 to
    eliminate everything between the parentheses and then the parentheses
    themselves so that Adams (Jefferson County) is left as Adams.

    Considering that there are 62 counties in NYS, including New York City's
    five boroughs, I want to avoid having to enter in the replace/find function,
    each county's name, enclosed within parentheses, in order to delete it.

    Is there a way to accomplish the above, for NYS, without having to do it 62
    times?

    Further, I want to do the same for all 50 states. Considering that there are
    over 3,000 counties, I hope to avoid having to use the find/replace function
    more than 3,000 times.

    Any and all advice/suggestions to achieve the above would be most
    appreciated!

    Thanks in advance!

    Martin
     
    Martin, Jul 12, 2007
    #1
    1. Advertisements

  2. Martin

    Loud Heart Guest

    Hi Martin,

    Here is your magic MS Word's regular expression to remove any character
    within the parentheses as well as the parentheses themselves. Also
    removing is any space character in front of the opening parentheses '('.

    Here are the steps:
    1. In MS Word, do a control H
    2. Enter ' *\(*\)' without the single quotes in the "Find what:" field
    and leave "Replace with:" empty.
    3. Click the "More" button
    4. Make sure the "Use wildcards" is checked.
    5. Now, use the "Find Next" and "Replace" or "Replace All" buttons see
    the changes.

    Good day.
     
    Loud Heart, Jul 12, 2007
    #2
    1. Advertisements

  3. Use wildcards. Google this common concept as needed.
     
    Blinky the Shark, Jul 12, 2007
    #3
  4. Martin

    Martin Guest

    Hello!

    Thank you very much for the instructions. For a reason unbeknownst to me, I
    had to remove the first * in order to preclude the entire contents of the
    doc being deleted. Must be a glitch in my Word app!

    Towns and cities in other states will be in the following format before
    being modified:
    Arley (town) Winston County
    Ashford (city) Houston County

    What I hope to be left with is Arley
    Ashford

    How do I remove, for instance, (town) Winston County or, for that matter,
    the name of any city or town followed by the name of the county in which
    it's located?

    Once again, thank you for your invaluable advice and I look forward to your
    next set of instructions.

    Best regards,

    Martin


    | Martin wrote:
    | > Hello,
    | >
    | > I am trying to create a Word doc that lists every town in New York
    State,
    | > but excludes the county in which the town is located.
    | >
    | > If it's relevant, my information comes from the U.S. Census.
    | >
    | > For instance, the town of Adams is in Jefferson County. The format that
    I'm
    | > accessing is as follows: Adams (Jefferson County).
    | >
    | > What I would like to do is use the find or replace function in Word 2002
    to
    | > eliminate everything between the parentheses and then the parentheses
    | > themselves so that Adams (Jefferson County) is left as Adams.
    | >
    | > Considering that there are 62 counties in NYS, including New York City's
    | > five boroughs, I want to avoid having to enter in the replace/find
    function,
    | > each county's name, enclosed within parentheses, in order to delete it.
    | >
    | > Is there a way to accomplish the above, for NYS, without having to do it
    62
    | > times?
    | >
    | > Further, I want to do the same for all 50 states. Considering that there
    are
    | > over 3,000 counties, I hope to avoid having to use the find/replace
    function
    | > more than 3,000 times.
    | >
    | > Any and all advice/suggestions to achieve the above would be most
    | > appreciated!
    | >
    | > Thanks in advance!
    | >
    | > Martin
    | >
    | >
    |
    | Hi Martin,
    |
    | Here is your magic MS Word's regular expression to remove any character
    | within the parentheses as well as the parentheses themselves. Also
    | removing is any space character in front of the opening parentheses '('.
    |
    | Here are the steps:
    | 1. In MS Word, do a control H
    | 2. Enter ' *\(*\)' without the single quotes in the "Find what:" field
    | and leave "Replace with:" empty.
    | 3. Click the "More" button
    | 4. Make sure the "Use wildcards" is checked.
    | 5. Now, use the "Find Next" and "Replace" or "Replace All" buttons see
    | the changes.
    |
    | Good day.
    | --
    | # WWW.LOUDHEART.COM
    | # classified ad + forum
    | # = a work in progress
     
    Martin, Jul 12, 2007
    #4
  5. Martin

    Loud Heart Guest

    You're welcome.

    Okay, regarding your second problem, you can try this regular expression.

    ' \(*\) * *>'

    Again, remove the opening and closing single quote character (') before
    using it. And you're right, Martin, regarding my previous post that the
    first * should be removed. Anyhow, the regular expression I stated
    above in this post will give you the following output.


    INPUT:
    Arley (town) Winston County
    Ashford (city) Houston County


    OUTPUT: NO TRAILING SPACE CHARACTER
    Arley
    Ashford


    Also, Martin, make sure there is a space character after the first
    opening single quote in the regular expression. Although it is not
    important for this single space character to exist, it does remove a
    trailing space character at the end of the word.

    For example, if you use the revised version below instead of the original

    ' \(*\) * *>' (original)
    '\(*\) * *>' (revised)

    your output looks normal except that you won't be able to see the
    trailing space character after "Arley" or "Ashford". Rather, your output is


    OUTPUT: WITH TRAILING SPACE CHARACTER INDICATED BY UNDERSCORE
    Arley_
    Ashford_


    Just want to point that out to you.

    Cheer.
     
    Loud Heart, Jul 12, 2007
    #5
  6. Martin

    Martin Guest

    Hello,

    Again, thank you very much for your instructions.

    I need to qualify some information that I provided.

    In many cases, using it as an example of others, a town/city and county will
    appear as:
    Cataula Harris County.

    Evidently, there are no parentheses separating Cataula and Harris County.
    It's still imperative that the name of the county be eliminated, so that
    only Cataula appears.

    Considering the lack of separator between the name of the town/city and its
    county, is my objective still achievable without manually using the
    find/replace function many hundreds of times?

    Thanks in advance!

    Regards,

    Martin



    | Martin wrote:
    | > Hello!
    | >
    | > Thank you very much for the instructions. For a reason unbeknownst to
    me, I
    | > had to remove the first * in order to preclude the entire contents of
    the
    | > doc being deleted. Must be a glitch in my Word app!
    | >
    | > Towns and cities in other states will be in the following format before
    | > being modified:
    | > Arley (town) Winston County
    | > Ashford (city) Houston County
    | >
    | > What I hope to be left with is Arley
    | > Ashford
    | >
    | > How do I remove, for instance, (town) Winston County or, for that
    matter,
    | > the name of any city or town followed by the name of the county in which
    | > it's located?
    | >
    | > Once again, thank you for your invaluable advice and I look forward to
    your
    | > next set of instructions.
    | >
    | > Best regards,
    | >
    | > Martin
    | >
    | >
    | > | > | Martin wrote:
    | > | > Hello,
    | > | >
    | > | > I am trying to create a Word doc that lists every town in New York
    | > State,
    | > | > but excludes the county in which the town is located.
    | > | >
    | > | > If it's relevant, my information comes from the U.S. Census.
    | > | >
    | > | > For instance, the town of Adams is in Jefferson County. The format
    that
    | > I'm
    | > | > accessing is as follows: Adams (Jefferson County).
    | > | >
    | > | > What I would like to do is use the find or replace function in Word
    2002
    | > to
    | > | > eliminate everything between the parentheses and then the
    parentheses
    | > | > themselves so that Adams (Jefferson County) is left as Adams.
    | > | >
    | > | > Considering that there are 62 counties in NYS, including New York
    City's
    | > | > five boroughs, I want to avoid having to enter in the replace/find
    | > function,
    | > | > each county's name, enclosed within parentheses, in order to delete
    it.
    | > | >
    | > | > Is there a way to accomplish the above, for NYS, without having to
    do it
    | > 62
    | > | > times?
    | > | >
    | > | > Further, I want to do the same for all 50 states. Considering that
    there
    | > are
    | > | > over 3,000 counties, I hope to avoid having to use the find/replace
    | > function
    | > | > more than 3,000 times.
    | > | >
    | > | > Any and all advice/suggestions to achieve the above would be most
    | > | > appreciated!
    | > | >
    | > | > Thanks in advance!
    | > | >
    | > | > Martin
    | > | >
    | > | >
    | > |
    | > | Hi Martin,
    | > |
    | > | Here is your magic MS Word's regular expression to remove any
    character
    | > | within the parentheses as well as the parentheses themselves. Also
    | > | removing is any space character in front of the opening parentheses
    '('.
    | > |
    | > | Here are the steps:
    | > | 1. In MS Word, do a control H
    | > | 2. Enter ' *\(*\)' without the single quotes in the "Find what:" field
    | > | and leave "Replace with:" empty.
    | > | 3. Click the "More" button
    | > | 4. Make sure the "Use wildcards" is checked.
    | > | 5. Now, use the "Find Next" and "Replace" or "Replace All" buttons see
    | > | the changes.
    | > |
    | > | Good day.
    | > | --
    | > | # WWW.LOUDHEART.COM
    | > | # classified ad + forum
    | > | # = a work in progress
    | >
    | >
    |
    | You're welcome.
    |
    | Okay, regarding your second problem, you can try this regular expression.
    |
    | ' \(*\) * *>'
    |
    | Again, remove the opening and closing single quote character (') before
    | using it. And you're right, Martin, regarding my previous post that the
    | first * should be removed. Anyhow, the regular expression I stated
    | above in this post will give you the following output.
    |
    |
    | INPUT:
    | Arley (town) Winston County
    | Ashford (city) Houston County
    |
    |
    | OUTPUT: NO TRAILING SPACE CHARACTER
    | Arley
    | Ashford
    |
    |
    | Also, Martin, make sure there is a space character after the first
    | opening single quote in the regular expression. Although it is not
    | important for this single space character to exist, it does remove a
    | trailing space character at the end of the word.
    |
    | For example, if you use the revised version below instead of the original
    |
    | ' \(*\) * *>' (original)
    | '\(*\) * *>' (revised)
    |
    | your output looks normal except that you won't be able to see the
    | trailing space character after "Arley" or "Ashford". Rather, your output
    is
    |
    |
    | OUTPUT: WITH TRAILING SPACE CHARACTER INDICATED BY UNDERSCORE
    | Arley_
    | Ashford_
    |
    |
    | Just want to point that out to you.
    |
    | Cheer.
    | --
    | # WWW.LOUDHEART.COM
    | # classified ad + forum
    | # = a work in progress
     
    Martin, Jul 12, 2007
    #6
  7. Martin

    Evan Platt Guest

    My guess is yes - as some cities and counties may have 1 or 2 or more
    words. But someone may prove me wrong.
     
    Evan Platt, Jul 12, 2007
    #7
  8. Martin

    Loud Heart Guest

    Martin,

    It is still possible to compose a regular expression if the county name
    consists only one word. However, there are counties that have more than
    one words, such as Santa Clara county of California. Hence, if you are
    working with data that is in this format "<CITY NAME> <COUNTY NAME>
    COUNTY" where <CITY NAME> and <COUNTY NAME> only consists of one word,
    then you can write up a regular expression to handle that. One the
    other hand, what if you have this

    "San Jose Santa Clara County"

    where city name = "San Jose" and county name = "Santa Clara".

    It is best if your data are delimited like the ones that we worked earlier.
     
    Loud Heart, Jul 12, 2007
    #8
  9. Martin

    Martin Guest

    Hello again,

    I very much appreciate the time expended and instructions given in helping
    me achieve my objective.

    Regards,

    Martin


    | Martin wrote:
    | > Hello,
    | >
    | > Again, thank you very much for your instructions.
    | >
    | > I need to qualify some information that I provided.
    | >
    | > In many cases, using it as an example of others, a town/city and county
    will
    | > appear as:
    | > Cataula Harris County.
    | >
    | > Evidently, there are no parentheses separating Cataula and Harris
    County.
    | > It's still imperative that the name of the county be eliminated, so that
    | > only Cataula appears.
    | >
    | > Considering the lack of separator between the name of the town/city and
    its
    | > county, is my objective still achievable without manually using the
    | > find/replace function many hundreds of times?
    | >
    | > Thanks in advance!
    | >
    | > Regards,
    | >
    | > Martin
    | >
    | >
    | >
    | > | > | Martin wrote:
    | > | > Hello!
    | > | >
    | > | > Thank you very much for the instructions. For a reason unbeknownst
    to
    | > me, I
    | > | > had to remove the first * in order to preclude the entire contents
    of
    | > the
    | > | > doc being deleted. Must be a glitch in my Word app!
    | > | >
    | > | > Towns and cities in other states will be in the following format
    before
    | > | > being modified:
    | > | > Arley (town) Winston County
    | > | > Ashford (city) Houston County
    | > | >
    | > | > What I hope to be left with is Arley
    | > | > Ashford
    | > | >
    | > | > How do I remove, for instance, (town) Winston County or, for that
    | > matter,
    | > | > the name of any city or town followed by the name of the county in
    which
    | > | > it's located?
    | > | >
    | > | > Once again, thank you for your invaluable advice and I look forward
    to
    | > your
    | > | > next set of instructions.
    | > | >
    | > | > Best regards,
    | > | >
    | > | > Martin
    | > | >
    | > | >
    | > | > | > | > | Martin wrote:
    | > | > | > Hello,
    | > | > | >
    | > | > | > I am trying to create a Word doc that lists every town in New
    York
    | > | > State,
    | > | > | > but excludes the county in which the town is located.
    | > | > | >
    | > | > | > If it's relevant, my information comes from the U.S. Census.
    | > | > | >
    | > | > | > For instance, the town of Adams is in Jefferson County. The
    format
    | > that
    | > | > I'm
    | > | > | > accessing is as follows: Adams (Jefferson County).
    | > | > | >
    | > | > | > What I would like to do is use the find or replace function in
    Word
    | > 2002
    | > | > to
    | > | > | > eliminate everything between the parentheses and then the
    | > parentheses
    | > | > | > themselves so that Adams (Jefferson County) is left as Adams.
    | > | > | >
    | > | > | > Considering that there are 62 counties in NYS, including New
    York
    | > City's
    | > | > | > five boroughs, I want to avoid having to enter in the
    replace/find
    | > | > function,
    | > | > | > each county's name, enclosed within parentheses, in order to
    delete
    | > it.
    | > | > | >
    | > | > | > Is there a way to accomplish the above, for NYS, without having
    to
    | > do it
    | > | > 62
    | > | > | > times?
    | > | > | >
    | > | > | > Further, I want to do the same for all 50 states. Considering
    that
    | > there
    | > | > are
    | > | > | > over 3,000 counties, I hope to avoid having to use the
    find/replace
    | > | > function
    | > | > | > more than 3,000 times.
    | > | > | >
    | > | > | > Any and all advice/suggestions to achieve the above would be
    most
    | > | > | > appreciated!
    | > | > | >
    | > | > | > Thanks in advance!
    | > | > | >
    | > | > | > Martin
    | > | > | >
    | > | > | >
    | > | > |
    | > | > | Hi Martin,
    | > | > |
    | > | > | Here is your magic MS Word's regular expression to remove any
    | > character
    | > | > | within the parentheses as well as the parentheses themselves.
    Also
    | > | > | removing is any space character in front of the opening
    parentheses
    | > '('.
    | > | > |
    | > | > | Here are the steps:
    | > | > | 1. In MS Word, do a control H
    | > | > | 2. Enter ' *\(*\)' without the single quotes in the "Find what:"
    field
    | > | > | and leave "Replace with:" empty.
    | > | > | 3. Click the "More" button
    | > | > | 4. Make sure the "Use wildcards" is checked.
    | > | > | 5. Now, use the "Find Next" and "Replace" or "Replace All" buttons
    see
    | > | > | the changes.
    | > | > |
    | > | > | Good day.
    | > | > | --
    | > | > | # WWW.LOUDHEART.COM
    | > | > | # classified ad + forum
    | > | > | # = a work in progress
    | > | >
    | > | >
    | > |
    | > | You're welcome.
    | > |
    | > | Okay, regarding your second problem, you can try this regular
    expression.
    | > |
    | > | ' \(*\) * *>'
    | > |
    | > | Again, remove the opening and closing single quote character (')
    before
    | > | using it. And you're right, Martin, regarding my previous post that
    the
    | > | first * should be removed. Anyhow, the regular expression I stated
    | > | above in this post will give you the following output.
    | > |
    | > |
    | > | INPUT:
    | > | Arley (town) Winston County
    | > | Ashford (city) Houston County
    | > |
    | > |
    | > | OUTPUT: NO TRAILING SPACE CHARACTER
    | > | Arley
    | > | Ashford
    | > |
    | > |
    | > | Also, Martin, make sure there is a space character after the first
    | > | opening single quote in the regular expression. Although it is not
    | > | important for this single space character to exist, it does remove a
    | > | trailing space character at the end of the word.
    | > |
    | > | For example, if you use the revised version below instead of the
    original
    | > |
    | > | ' \(*\) * *>' (original)
    | > | '\(*\) * *>' (revised)
    | > |
    | > | your output looks normal except that you won't be able to see the
    | > | trailing space character after "Arley" or "Ashford". Rather, your
    output
    | > is
    | > |
    | > |
    | > | OUTPUT: WITH TRAILING SPACE CHARACTER INDICATED BY UNDERSCORE
    | > | Arley_
    | > | Ashford_
    | > |
    | > |
    | > | Just want to point that out to you.
    | > |
    | > | Cheer.
    | > | --
    | > | # WWW.LOUDHEART.COM
    | > | # classified ad + forum
    | > | # = a work in progress
    | >
    | >
    |
    | Martin,
    |
    | It is still possible to compose a regular expression if the county name
    | consists only one word. However, there are counties that have more than
    | one words, such as Santa Clara county of California. Hence, if you are
    | working with data that is in this format "<CITY NAME> <COUNTY NAME>
    | COUNTY" where <CITY NAME> and <COUNTY NAME> only consists of one word,
    | then you can write up a regular expression to handle that. One the
    | other hand, what if you have this
    |
    | "San Jose Santa Clara County"
    |
    | where city name = "San Jose" and county name = "Santa Clara".
    |
    | It is best if your data are delimited like the ones that we worked
    earlier.
    | --
    | # WWW.LOUDHEART.COM
    | # classified ad + forum
    | # = a work in progress
     
    Martin, Jul 13, 2007
    #9
  10. Martin

    Loud Heart Guest

    No problem. If you are looking for further assistance, you might want
    to join the microsoft.public.word newsgroup.
     
    Loud Heart, Jul 13, 2007
    #10
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.