• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 472
  • Last Modified:

Regex.Replace never finishes...

When I run the code below the Regex.Replace never finishes.  It sends my CPU up to 100% for a few minutes, never throws an exception or anything.  Just never finishes.  Any ideas what i'm doing wrong?
//string s = {up to 1000 lines of markup};
string match = @"(?:<(\w+)\b[^>]*class=""[^""]*title[^""]*""[^>]*>[\s\S]*?<\/\1|[\S\s])*?([^<\w](XXX?e?s?)[^>\w])(?![^<>\w]*>)";
string replacement = "<span class=\"withHelp\" style=\"text-decoration: underline\" title=\"XXX\">$3</span>";
    s = Regex.Replace(s, match, replacement, RegexOptions.IgnoreCase | RegexOptions.Multiline);

Open in new window

  • 10
  • 8
  • 3
  • +1
1 Solution
Please provide the input string so we can reproduce the error.
abemiesterAuthor Commented:
<div id="page">
<a name="top"></a>
<a href="#A">A</a> |
<a href="#B">B</a> |
<a href="#C">C</a> |
<a href="#D">D</a> |
<a href="#E">E</a> |
<a href="#F">F</a> |
<a href="#G">G</a> |
<a href="#H">H</a> |
<a href="#I">I</a> |
<a href="#J">J</a> |
<a href="#K">K</a> |
<a href="#L">L</a> |
<a href="#M">M</a> |
<a href="#N">N</a> |
<a href="#O">O</a> |
<a href="#P">P</a> |
<a href="#Q">Q</a> |
<a href="#R">R</a> |
<a href="#S">S</a> |
<a href="#T">T</a> |
<a href="#U">U</a> |
<a href="#V">V</a> |
<a href="#W">W</a> |
<a href="#X">X</a> |
<a href="#Y">Y</a> |
<a href="#Z">Z</a>
<br />
<br />

<p class="title" align="center"><a name="A"><u>A</u></a></p>

<p class="title">Accommodations</p>

<p>Accommodations are the adjustments made to the environment so that people with disabilities are not excluded from access to services, buildings, employment, housing, or other aspects of public life.</p>

<p>Accommodations can include making facilities accessible with ramps, elevators, and door openers; providing assistive devices and equipment; and providing readers or interpreter services.</p>

<p class="title">Adult Protective Services</p>

<p>Each county has an Adult Protective Services (APS) agency that assists elderly and dependent adults who are possible victims of the crimes of abuse, exploitation, or neglect. </p>

<p>APS agencies investigate reports of abuse that occur in private homes, acute care hospitals, clinics, adult day care facilities, and social day care centers. </p>

<p>APS agencies provide a 24-hour-a-day, 7-day-a-week telephone hotline to respond to all reports of suspected abuse. APS agencies in some counties also provide case management services, emergency shelter or in-home protection, transportation, and/or counseling services. Contact the Adult Protective Services unit of your county social services agency.</p>

<p class="title">Advance Health Care Directive (AHCD)</p>

<p>The Advance Health Care Directive is now the legally recognized document for a living will and medical power of attorney in California. </p>

<p>This document allows you to write down your wishes about the care you want to receive (or refuse), for others to reference if you become unable to make health care decisions for yourself. </p>

<p>It can also designate someone you trust to make decisions about your medical care if you are unable to make or communicate those decisions. </p>

<p>Effective July 1, 2000, the Natural Death Act and the laws governing Durable Powers of Attorney for Health Care were replaced by the new Health Care Decisions Law (AB 891-Chapter 658). (link to http://www.leginfo.ca.gov/pub/99-00/bill/asm/ab_0851-0900/ab_891_bill_19991010_chaptered.html )This new and greatly improved law increases the value and acceptance of advance directives.</p>

<p class="title">Affordable Housing</p>

<p>This is housing that people with low and moderate income can afford. The term applies to both renting and buying a home.</p>

<p class="title">Alzheimer's Disease</p>

<p>Alzheimer's Disease (AD) is an irreversible, progressive brain disease that slowly destroys memory and thinking skills and, eventually, the ability to carry out the simplest tasks of daily living. </p>

<p>AD can be a cause of dementia among older people, but not all memory problems indicate AD. There are a number of types of dementia (a decline in cognitive function that interferes with your ability to think and understand). Although treatment can slow the progression of AD and help manage its symptoms in some people, there is no cure for this devastating disease yet.</p>

<p class="title">Assisted Living</p>

<p>Assisted Living usually means a group living, non-medical facility where people have apartment-like living spaces and pay a monthly fee for room and board.  Assisted Living residents often share common areas like dining rooms and activity rooms.  In California, Assisted Living facilities are licensed as Residential Care Facilities for the Elderly (RCFE) by the California Department of Social Services/Community Care Licensing Division.  </p>

<p>Assisted Living Waiver Program (ALW)</p>

<p>The Assisted Living Waiver (ALW) is a Medi-Cal benefit that pays for care coordination and other specified benefits if you live in a Residential Care Facility for the Elderly (RCFE) or in HUD housing. It is available to Medi-Cal eligible seniors and people with disabilities who live in Sacramento, San Joaquin and Los Angeles counties. Other counties will be added over time.</p>

<p class="title">Assistive Devices</p>

<p>Assistive devices are tools, products, or equipment that make your life easier and help you remain independent. They can help you move around, see, communicate, eat, or get dressed.</p>

<p>Some assistive devices are high-tech, such as computers. Others are simpler, like a "reacher"-a tool that helps you grab an object from a shelf that you couldn't reach otherwise.</p>

<p><a href="#top">Return to top of glossary</a></p>

<p class="title" align="center"><a name="B"><u>B</u></a></p>

<p class="title">Bonded Workers</p>

<p>Bonded workers are insured through their company. If you hire a bonded worker who causes a problem while working, the company guarantees you payment to cover your loss.</p>

<p>Hiring someone to work in your home can be risky; hiring bonded workers adds financial protection for you.</p>

<p><a href="#top">Return to top of glossary</a></p>

<p class="title" align="center"><a name="C"><u>C</u></a></p>

<p class="title">California Partnership for Long-Term Care</p>

<p>The California Partnership for Long-Term Care is dedicated to educating Californians about the need to plan ahead for their future long-term care services by purchasing private long-term care insurance to fund that care. </p>

<p>This innovative program of the State of California Department of Health Care Services works with a number of private insurance companies. </p>

<p>These companies agree to offer high quality policies (called "partnership policies") that must meet strict requirements set by the Partnership and the State of California. Partnership policies take the guesswork out of making sure you purchase a quality policy.</p>

<p>In addition to many other consumer protection features, Partnership policies offer the special benefit of Medi-Cal Asset Protection.</p>

<p class="title">CalWORKs</p>

<p>CalWORKs (California Work Opportunity and Responsibility to Kids) is a program that provides cash aid and services to eligible needy California families. The program serves all 58 counties and is operated locally by county social service departments. </p>

<p>If your family has little or no cash and needs housing, food, utilities, clothing, or medical care, you may be eligible to receive immediate short-term help. Families that apply and qualify for ongoing assistance receive money each month to help pay for housing, food, and other necessary expenses.</p>

<p class="title">Caregiver</p>

<p>A caregiver is a person who is responsible for attending to the needs of a child, dependent adult, or elder. </p>

<p>Caregivers may be paid or unpaid. Caregivers may be family members or professional workers. Caregiver training and support is a key component of long-term care services whether services are provided in a facility or at home.</p>

<p class="title">Case Manager</p>

<p>A case manager is usually a social worker or nurse who helps you coordinate all your services and service providers. A case manager can help you set up a service plan for the short term or the long term. </p>

<p>"Service coordination" and "care management" are other terms used for this service.</p>

<p class="title">COBRA Coverage</p>

<p>COBRA is a federal law that requires employers with 20 or more employees to notify you of the opportunity to continue group health insurance coverage even after you've left their employment.</p>

<p>This offers you and your family the opportunity for a guaranteed temporary extension of health coverage when you leave the company. </p>

<p>You must pay for this coverage, including the portion of your health insurance that your employer paid for you when you were an employee.  There have been recent changes expanding the COBRA opportunity.  Check with your employer's human resources department (or personnel department) and research COBRA facts on the internet to see if you can benefit from these changes.</p>

<p class="title">Code Enforcement</p>

<p>Cities, counties, and states have legal codes that set standards for contractors and businesses. People who do work for you in your home or people who care for others in a group home or facility must meet local and state building, fire, and other codes. </p>

<p>Local boards or government organizations that enforce codes can provide information on area contractors and businesses. They provide helpful tips on how to hire a contractor. They also report on contractors' license and bond status, pending complaints, and pending or prior legal actions.</p>

<p class="title">Chronic Condition</p>

<p>A chronic condition is an injury, illness, or other physical or mental condition that may last a long time without any predictable end. Some chronic conditions require ongoing attention and periodic medical care.  Find out about your chronic conditions on the internet, at the library and ask your doctor to explain your conditions and what the options are to manage them.  Find support groups and meet other people who have the same condition. </p>

<p><a href="#top">Return to top of glossary</a></p>

<p class="title" align="center"><a name="D"><u>D</u></a></p>

<p class="title">Dementia</p>

<p>Dementia is used to describe a group of conditions that affect the brain. It is not a specific disease. </p>

<p>People with dementia may not be able to think well enough to do normal activities, such as getting dressed or eating. They may lose their ability to solve problems or control their emotions. Their personalities may change. They may become agitated or see things that are not there.</p>

<p>Memory loss is a common symptom of dementia. However, memory loss by itself does not mean you have dementia. People with dementia have serious problems with two or more brain functions, such as memory and language.</p>

<p>Many different diseases can cause dementia, including Alzheimer's disease and stroke.</p>

<p class="title">Developmental Disability</p>

<p>In California, a developmental disability is defined as one that affects a child before the age of three and results in mental retardation, cerebral palsy, epilepsy, autism, or other disabling conditions.</p>

<p>In California, individuals and their families are supported with service planning and coordination by a local regional center. Assessment is performed in three or more of the following areas: receptive and expressive language, learning, self-care, mobility, self-direction, capacity for independent living, and economic self-sufficiency.</p>

<p class="title">Developmental Services</p>
<p>The California Department of Developmental Services is the agency that provides services and supports to people with developmental disabilities.</p>

<p>Services are provided through state-operated developmental centers and community facilities, and through 21 nonprofit regional centers.</p>

<p class="title">Disability Benefits</p>

<p>The Social Security and Supplemental Security Income disability programs are state and federally funded and provide assistance to people with disabilities. Only people who have a disability and meet medical criteria may qualify for benefits under either program.</p>
<p>While these two programs are different in many ways, both are administered by the Social Security Administration. </p>
        Social Security Disability Insurance pays benefits to you and certain members of your family if you are "insured," meaning that you worked long enough and paid enough Social Security taxes.
        Supplemental Security Income pays benefits based on financial need.

<p class="title">Distinct Part Facility</p>

<p>A Distinct Part Facility is usually a section of a hospital that has some rooms for people who no longer need hospital care but do need skilled nursing and rehabilitative services. People staying in this type of facility are typically recovering from surgery or an acute illness.</p>

<p><a href="#top">Return to top of glossary</a></p>

<p class="title" align="center"><a name="E"><u>E</u></a></p>

<p class="title">Elder Abuse (Dependent Adult Abuse)</p>

<p>Elder or dependent adult abuse is a crime and can fall under several categories:</p>
    <li>Physical abuse: Slapping, bruising, sexually molesting, or restraining</li>
    <li>Psychological abuse: Humiliating, threatening, or isolating</li>
    <li>Financial abuse: Using the cash or savings belonging to an elderly or dependent person without his/her consent</li>
    <li>Neglect: Failure to provide the care necessary to prevent physical harm, mental anguish, or illness</li>

<p>Report suspected elder or dependent adult abuse to your local police or sheriff, or to Adult Protective Services for people who live at home, or to California's Long-Term Care Ombudsman Office for people who live in a nursing home or assisted living facility.</p>

<p><a href="#top">Return to top of glossary</a></p>

<p class="title" align="center"><a name="H"><u>H</u></a></p>

<p class="title">Health Insurance Counseling and Advocacy (HICAP)</p>

<p>HICAP is a service provided by the California Department of Aging. Local HICAP programs offer consumer information and assistance with Medicare, Medicare supplemental policies, Health Maintenance Organizations (HMOs), and long-term care insurance.</p>

<p class="title">Home Health Agencies </p>

<p>Home health agencies may offer a wide range of services, including nursing care, personal care services, medical supplies, coordination with physical therapy, and caregiver training. Most home health agencies assess your needs, write up a care plan, and assemble a care team for you. </p>

<p>Home health agencies in California are licensed by the Department of Public Health. Some home health care agencies are Medicare and Medi-Cal-certified, which means they have met federal minimum requirements.</p>

<p class="title">Home Health Aides</p>

<p>Home health aides are trained to help you with daily personal care in your home if you are elderly or disabled. </p>
<p>Home health aides-also called caregivers, companions, and personal attendants-provide routine personal care services like helping you get out of bed, bathe, dress, and groom. Some accompany you to doctors' appointments or on other errands.</p>

<p class="title">Hospice</p>
<p>Hospice is a type of care that allows people facing the end of life to live in comfort, at peace, and in control. It provides services in the comfort and dignity of your home; to let you stay in a warm, familiar environment, surrounded by family and friends; and to let you be in control of your own plan of care when curative treatment is no longer successful or desired.</p>

<p>Hospice affirms life and accepts dying as a natural process. It helps prepare you and family members for a peaceful death. </p>

<p>Hospice services can also be provided to you and your family in a facility. Hospice services are typically considered when the outlook for end of life is six months or less.</p>

<p>Housing and Urban Development (HUD)</p>

<p>This department within the federal government is mandated by Congress to create decent and affordable housing, to ensure equal housing opportunities, and to strengthen and enrich the nation's communities. </p>

<p>Offices are located at the national and state levels. Locally, HUD does business with housing authorities and furnishes HUD vouchers for people who qualify. There may be a waiting list.</p>

<p><a href="#top">Return to top of glossary</a></p>

<p class="title" align="center"><a name="I"><u>I</u></a></p>

<p class="title">Independent Living Center</p>

<p>Independent Living Centers are nonresidential, nonprofit, consumer-controlled organizations based in communities. They provide services and advocacy for people with disabilities. </p>

<p>Their goal is to assist you to achieve your full potential and to continue your lifestyle with your family, friends, and community. Independent Living Centers serve as a strong advocacy voice on a range of national, state, and local issues. They work to assure access to housing, employment, transportation, communities, recreational facilities, and health and social services.</p>

<p class="title">Independent Living Skills</p>

<p>Independent Living Skills are the skills you need to perform everyday tasks and to maintain your independence and place in the community. These skills are unique to your culture and lifestyle. They include: </p>

    <li>Food preparation</li>
    <li>Household management</li>
    <li>Money management</li>
    <li>Use of public transportation</li>
    <li>Social skills</li>
    <li>Job interviewing</li>

<p class="title">Institutional Deeming Rules</p>

<p>Institutional Deeming is a special Medi-Cal eligibility rule that enables you to get Medi-Cal eligibility as if you were in a long-term care facility (such as a nursing facility) even though you may be receiving services at home. </p>

<p>In determining Medi-Cal eligibility, this rule considers only the personal income and resources of a person who is under the age of 18 or is a married adult. If you meet certain criteria, this allows you to become eligible for Medi-Cal regardless of your parent's or spouse's income or resources.</p>

<p>Return to top of glossary

<p class="title" align="center"><a name="L"><u>L</u></a></p>

<p class="title">Law Enforcement</p>

<p>Law enforcement agencies can prosecute crimes committed against elderly and dependent adults who are functionally impaired, and who are possible victims of abuse, exploitation, or neglect.  </p>

<p>Some local law enforcement agencies have Elder Abuse Units. Call the general police or sheriff information number and ask if they have an Elder Abuse Unit. If there is a life-threatening emergency, call 911 immediately.</p>

<p>Some county district attorney and city attorney offices have units devoted to the investigation and prosecution of elder abuse.</p>

<p>The Department of Justice Bureau of Medi-Cal Fraud and Elder Abuse is dedicated to safeguarding the elderly and protecting the health care system that serves the less fortunate members of our population.</p>

<p class="title">Licensed Facility</p>

<p>Licensed facilities are managed by organizations that have been granted government approval to provide specialized care or services. The license may specify a specific group or number of people to be served. Licensing ensures the facility meets certain standards and staffing requirements. </p>

<p>In California, examples of licensed facilities include: Nursing facilities, Adult Day Health Care Centers (ADHC), Residential Care Facilities for the Elderly (RCFE), and others. Although Home Health Care Agencies are not "facilities," they are required to be licensed in California.</p>

<p class="title">Long-term Care Insurance</p>

<p>Long-term care insurance covers services that regular health insurance usually does not cover. </p>

<p>People who need long-term care services have ongoing physical or mental disabilities and are unable to perform one or more basic activities of daily living. These typically include dressing, bathing, eating, using the bathroom, transferring (getting in and out of a bed or chair), and walking. </p>

<p>You can buy long-term care insurance by paying a monthly premium for the coverage that you think will meet your future needs. Be sure you compare plans and understand the costs and the services you will get when and if the time comes that you need services.</p>

<p class="title">Long-term Services and Supports</p>

<p>Long-term care services and supports is a general term that includes all the different kinds of services that are necessary to address your long-term needs because of disability or chronic conditions.</p>

<p>Also called long-term care, these are health care services and social supports in any setting; for example, at home, in assisted living, or in a nursing facility. </p>

<p><a href="#top">Return to top of glossary</a></p>

<p class="title" align="center"><a name="M"><u>M</u></a></p>

<p class="title">Managed Health Care Plan (Managed-Care Plan)</p>

<p>A managed health care plan is an organization that combines the financing and delivery of health care within a single system. </p>

<p>The plan manages the cost, accessibility, and quality of care for enrolled members. Enrolled members typically use a network of health care providers who work with the plan. </p>

<p>With few exceptions, managed health care plans must be licensed by the State of California Department of Managed Health Care.</p>

<p class="title">Medicaid</p>

<p>Medicaid is the name of the federal health care insurance program for people who have low income. Medicaid is managed by the states-in California, Medicaid is called Medi-Cal. </p>

<p>Medi-Cal covers hospital care, doctor visits, surgery, out-patient services, and long-term care services in a facility or at home.</p>

<p>Among the people served by Medi-Cal are low-income adults, children, seniors, people with disabilities, and people who receive long-term care services in a facility or at home.</p>

<p class="title">Medi-Cal</p>

<p>Medi-Cal is the name of California's Medicaid program. Medi-Cal provides health care coverage for low-income individuals; including children and families. It also covers costs for long-term care services for eligible individuals in a nursing facility, at home or in the work place.  . </p>

<p>Medi-Cal is funded by the state and federal governments, and the California Department of Health Care Services administers it. You can apply for Medi-Cal by contacting your county social services department. Ask for the Medi-Cal eligibility worker.</p>

<p class="title">Medicare</p>

<p>Medicare provides health care primarily to Americans over 65. If you have Medicare coverage, you pay for Medicare premiums, deductibles, and co-payments.</p>

<p>Medicare has four parts: </p>

    <li>Part A provides hospital coverage</li>
    <li>Part B provides outpatient medical coverage</li>
    <li>Part C offers coverage through "Medicare Advantage" managed-care plans</li>
    <li>Part D offers enrollment in one of several prescription drug plans</li>

<p>Some people are eligible for both Medicare (over 65) and Medi-Cal (for example, those with low income). For assistance and information, contact the Health Insurance Counseling and Advocacy Program (HICAP) for Medicare and your county social services department for Medi-Cal.</p>

<p class="title">Medicare Advantage Plans</p>

<p>Medicare Advantage Plans are health plan options that are part of the Medicare program. If you enroll in one of these plans, you generally get all your Medicare-covered health care through that plan. This coverage can include prescription drug coverage. Medicare Advantage Plans can be:</p>

    <li>Medicare Health Maintenance Organizations (HMOs)</li>
    <li>Preferred Provider Organizations (PPOs)</li>
    <li>Private Fee-for-Service Plans</li>
    <li>Medicare Special Needs Plans</li>

<p>When you enroll in a Medicare Advantage Plan, you use a health insurance card you receive from the plan for your health care. In some of these plans, there can be extra benefits and lower co-payments. You may be limited to doctors who belong to the plan and certain hospitals and service providers.</p>

<p class="title">Medicare Supplemental Insurance (Medigap)</p>

<p>Medigap is supplemental health insurance that you buy to cover medical expenses that are not covered or only partly covered by Medicare. (These policies typically don't cover long-term care services.)</p>

<p>Medigap's name refers to how the program covers the difference, or "gap," between the costs covered by Medicare and the total cost of the services or products.</p>

<p><a href="#top">Return to top of glossary</a></p>

<p class="title" align="center"><a name="O"><u>O</u></a></p>

<p class="title">Ombudsman</p>

<p>An ombudsman is an official who investigates and resolves complaints. The California Long-Term Care Ombudsman program handles concerns for people in nursing facilities or residential care facilities for the elderly.</p>

<p><a href="#top">Return to top of glossary</a></p>

<p class="title" align="center"><a name="P"><u>P</u></a></p>

<p class="title">Personal Emergency Response System (PERS)</p>

<p>This is an electronic device that works with your telephone to summon help in an emergency.</p>

<p>A PERS system usually requires installed equipment and a monthly cost for monitoring service. In some situations Medicare, Medicaid, or private insurance cover partial costs of a PERS. You might need a doctor's order (prescription) for the PERS. Some hospitals and social service agencies will help with PERS fees for low-income disabled users.</p>

<p class="title">Personal Care Services</p>

<p>Personal care services are provided by a person trained to help you with bathing, dressing, eating, going to the bathroom, getting around, and other activities of daily living. </p>

<p>Your county operates the In-Home Supportive Services (IHSS) program, which provides publicly funded personal care services if you need assistance with activities of daily living and you have low income.</p>

<p class="title">Private Pay</p>

<p>Private payments for health care and long-term care services are funds paid by you from your own income or savings when you are not eligible for public (government funded) programs or services.</p>

<p class="title">Psychiatric Condition</p>

<p>A psychiatric condition is a symptom or behavior associated with mental illness. </p>

<p>Common psychiatric conditions can include dissociative disorders, mood disorders, anxiety, psychotic episodes, hallucinations, eating disorders, and personality disorders.</p>

<p><a href="#top">Return to top of glossary</a></p>

<p class="title" align="center"><a name="R"><u>R</u></a></p>

<p class="title">Rehabilitation</p>

<p>Rehabilitation services and supports help you return to a full productive life and maintain the highest possible level of function for your disability or chronic condition. </p>

<p>Rehabilitation may involve physical therapy, physical restoration of function (such as the use of prostheses), or emotional support (such as counseling or mentoring). Vocational rehabilitation includes supports necessary to re-enter the job market.  Long-term services and supports may be needed when rehabilitation no longer is effective and your chronic conditions or disabilities have not or cannot be improved. </p>

<p class="title">Residential Care for the Elderly (RCFE)</p>

<p>Residential Care Facilities for the Elderly (RCFE) provide room, board, housekeeping, supervision, and personal care assistance to the elderly.</p>

<p>Facilities usually store and distribute medications but do not provide nursing care. </p>

<p>RCFEs are considered nonmedical facilities and are not required to have nurses, certified nursing assistants, or doctors on staff. </p>

<p>Other terms that refer to RCFEs are assisted living facilities, board and care homes, and rest homes. </p>

<p>RCFEs are licensed by the California Department of Social Services/Community Care Licensing Division. Assisted Living facilities in California are licensed as RCFEs.</p>

<p class="title">Respite Services</p>

<p>Respite services provide a caregiver with a temporary break from the daily responsibilities of caring for people with physical or mental disabilities. </p>

<p>If you are receiving care, respite can be provided for your regular caregiver by a temporary caregiver in your home or by a health care facility where you can be safe while your regular caregiver gets a break.</p>

<p><a href="#top">Return to top of glossary</a></p>

<p class="title" align="center"><a name="S"><u>S</u></a></p>

<p class="title">Social Security</p>

<p>Social Security is a federal program that provides benefits including a monthly retirement income for people who have paid taxes during their income-earning years. </p>

<p>The program also provides a benefit to qualified people with disabilities, as well as to the widows, widowers, and surviving dependent children of qualified deceased workers.</p>

<p class="title">Social Security Administration (SSA)</p>

<p>The United States Social Security Administration (SSA) administers the Social Security retirement program, as well as disability and survivors' benefits. </p>

<p>To qualify for these benefits, American workers pay Social Security taxes on their earnings. Benefits are then based on the employees' past contributions. </p>

<p>SSA also coordinates with the state to administer the Supplemental Security Income (SSI) program, which is the needs-based income program for elderly and disabled people.</p>

<p class="title">Social Worker</p>

<p>A social worker is a trained professional who can help you coordinate your services after a hospital stay, illness, or injury. They can help you find and apply for services that can support your re-entry into family and community life.</p>

<p>Social workers also work as care managers, hospice counselors, and coordinators in long-term care facilities.</p>

<p class="title">Subsidized Housing</p>

<p>Subsidized housing is government-supported housing for people with low to moderate incomes. </p>

<p>Forms of subsidies include direct housing, nonprofit housing, public housing, rent supplements, and some forms of cooperative and private sector housing.</p>

<p>Supplemental Security Income / State Supplemental Payment (SSI/SSP)</p>

<p>Supplemental Security Income/State Supplementary Payment (SSI/SSP) is an income program funded by the federal and state governments. </p>

<p>It pays a minimum monthly income for single people and couples who are over 65 or disabled, and have very limited income and resources.</p>

<p>Eligibility for Supplemental Security Income/State Supplementary Payment (SSI/SSP) also makes you eligible for Medi-Cal.</p>

<p><a href="#top">Return to top of glossary</a></p>

<p class="title" align="center"><a name="V"><u>V</u></a></p>

<p class="title">Vocational Rehabilitation Services (VRS)</p>

<p>Vocational Rehabilitation Services (VRS) are counseling and other services that help you train for a new job or keep your existing job when you live with a new or long-term disability. VRS is a state-operated service administered by the Department of Rehabilitation.</p>

<p><a href="#top">Return to top of glossary</a></p>

<p class="title" align="center"><a name="W"><u>W</u></a></p>

<p class="title">XXX</p>

<p>XXX pays benefits to an employee (or an employee's family) if the employee suffers a job-related injury, disease, or death. All businesses with 20 or more employees must carry XXX insurance.</p>

<p><a href="#top">Return to top of glossary</a></p>

If those "" are folding to null strings, then the resulting regex might match a string in exponentially many ways
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

I ran your code and got the results below, is this what you expected?

Also, in order to get the exception you need to catch it after the try block.
<span class="withHelp" style="text-decoration: underline" title="XXX">XXX</span><span class="withHelp" style="text-decoration: underline" title="XXX">XXX</span>insurance.</p>
<p><a href="#top">Return to top of glossary</a></p>

Open in new window

abemiesterAuthor Commented:
i belive that's how you escape double quotes in a string, right?
you escape quotes with a backslash


"\"" which is the string "
Some languages do it that way, others do it differently.  I was looking for an interpretation that produces a regular expression that takes a very long time to finish
abemiesterAuthor Commented:
I have a try/catch in my test code.  That is the result i expected but when i run it on my machine it never finishes or throws an exception...  Could you paste up the function you're using for testing?
I did not change anything in your code except read the data from a file.

StreamReader reader = new StreamReader("file.txt");
string data = reader.ReadToEnd();
string match = @"(?:<(\w+)\b[^>]*class=""[^""]*title[^""]*""[^>]*>[\s\S]*?<\/\1|[\S\s])*?([^<\w](XXX?e?s?)[^>\w])(?![^<>\w]*>)";
string replacement = "<span class=\"withHelp\" style=\"text-decoration: underline\" title=\"XXX\">$3</span>";
string newData;
    newData = Regex.Replace(data, match, replacement, RegexOptions.IgnoreCase | RegexOptions.Multiline);
catch (Exception ex)
    string temp = ex.Message;

Open in new window

abemiesterAuthor Commented:
In C# you can use "" to represent " if you add an @ before the string.
string test = @"this is a ""test"".  see?";
abemiesterAuthor Commented:
Hey Ryan,
I tried your function and it worked.  I'll have to find what's different between my project and yours.
abemiesterAuthor Commented:
hey Ryan,
Does the code below throw an exception for you?  It seems to break on my machine when i change XXX to SSS.  Are your results the same?
            StreamReader reader = new StreamReader(@"c:\temp\file.txt");
            string data = reader.ReadToEnd();
            string match = "(?:<(\\w+)\\b[^>]*class=\"[^\"]*title[^\"]*\"[^>]*>[\\s\\S]*?<\\/\\1|[\\S\\s])*?([^<\\w](SSS?e?s?)[^>\\w])(?![^<>\\w]*>)";
            string replacement = "<span class=\"withHelp\" style=\"text-decoration: underline\" title=\"The legal document in California that describes in advance what health care you do or do not want to receive, in case a time comes when you can't make those choices yourself. It can also name a person you trust to make health care decisions for you.\">$3</span>";
            string newData;
                newData = Regex.Replace(data, match, replacement, RegexOptions.IgnoreCase | RegexOptions.Multiline);
            catch (Exception ex)
                string temp = ex.Message;

Open in new window

abemiesterAuthor Commented:
alright i think i found a solution.  Adding RegexOptions.Compiled appears to fix the infinite loop issue.  Not sure why this is but it looks like it fixed the issue i was talking about.
abemiesterAuthor Commented:
Never mind I'm still having the infinite loop issue...
It hangs for me too. I also noticed it hangs on the calls below

Could it have something to do with your Groupings? The regex enclosed in ( ).
Regex regex = new Regex(match, RegexOptions.IgnoreCase | RegexOptions.Multiline);
bool result = regex.IsMatch(data);
var matches = regex.Matches(data);
int count = matches.Count;

Open in new window

Could you just use s.replace("SearchForThisText", "ReplaceWithThisText")
nhenny2009, no because that signature does not exist for Replace().
Oops, You're not even talking about regex. But still, we're assuming abemiester's input is dynamic...
I use it even when the input is dynamic...hmmm
Take a look here, maybe this will help you...maybe it won't (depending on the type of input?)

nhenny2009, String.Replace does not have the search capabilities regular expressions has.
abemiesterAuthor Commented:
I believe this is a Microsoft bug.  I'll post back if I ever find a resolution.
abemiesterAuthor Commented:
Never found a real solutions for this.  
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 10
  • 8
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now