12 Short lesson: Regular Expressions
12.1 Tidyverse string expressions
When we load the Tidyverse, as above, one of the libraries included is stringr
,
which provides a set of functions for working with strings.
These seem decieptively simple, but they have some powerful features that we’ll want to look at. Let’s start by reviewing the basics.
For this example, we’ll look at a short Wikipedia article. We can download it and load its contents using the following code:
## [1] "\nOn 26 July 1184, Henry VI, King of Germany (later Holy Roman Emperor), held a Hoftag (informal assembly) at the cathedral provostry in Erfurt. The combined weight of the assembled nobles caused the wooden second storey floor of the building to collapse. Most of the attendants fell through into the latrine cesspit below the ground floor, where about 60 of them drowned in liquid excrement. This event is called the Erfurter Latrinensturz (lit. 'Erfurt latrine fall') in several German sources.[1][2][3]A feud between Landgrave Louis III of Thuringia and Archbishop Conrad of Mainz, which had existed since the defeat of Henry the Lion, intensified to the point that King Henry VI was forced to intervene while he was traveling through the region during a military campaign against Poland. Henry decided to call a diet in Erfurt, where he was staying, to mediate the situation between the two, and invited a number of other figures to the negotiations.[4]All of the nobles across the Holy Roman Empire were invited to the meeting, and many arrived on 25 July to attend.[5] Just as the assembly began, the wooden floor of the deanery, in which the nobles were sitting, broke under the stress, and people fell down through the first floor into the latrine in the cellar. About 60 people are said to have died,[6] including Count Gozmar III of Ziegenhain, Count Friedrich I of Abenberg [de], Burgrave Friedrich I of Kirchberg [de], Count Heinrich I of Schwarzburg [de], Count Burgrave Burchard von Wartburg, Count Hansteiner of Liechtenstein and Beringer von Wellingen.[7][8]King Henry was said to have survived only because he sat in an alcove with a stone floor[5] and was later saved using ladders. He departed as soon as possible. Landgrave Louis III of Thuringia survived as well.[5]Of those who died, many drowned in human excrement or suffocated from the fumes emitted by the decomposing waste, while others were crushed by falling debris.\n"
Some of the most important stringr
functions are as follows:
str_detect()
simply returns a TRUE or FALSE depending on whether the pattern
is found in the string.
## [1] TRUE
str_replace()
and str_replace_all()
replace the pattern with a new string.
## [1] "\nOn 26 July 1184, Henry VI, King of Germany (later Holy Roman Emperor), held a Hoftag (informal assembly) at the cathedral provostry in Zurich. The combined weight of the assembled nobles caused the wooden second storey floor of the building to collapse. Most of the attendants fell through into the latrine cesspit below the ground floor, where about 60 of them drowned in liquid excrement. This event is called the Zuricher Latrinensturz (lit. 'Zurich latrine fall') in several German sources.[1][2][3]A feud between Landgrave Louis III of Thuringia and Archbishop Conrad of Mainz, which had existed since the defeat of Henry the Lion, intensified to the point that King Henry VI was forced to intervene while he was traveling through the region during a military campaign against Poland. Henry decided to call a diet in Zurich, where he was staying, to mediate the situation between the two, and invited a number of other figures to the negotiations.[4]All of the nobles across the Holy Roman Empire were invited to the meeting, and many arrived on 25 July to attend.[5] Just as the assembly began, the wooden floor of the deanery, in which the nobles were sitting, broke under the stress, and people fell down through the first floor into the latrine in the cellar. About 60 people are said to have died,[6] including Count Gozmar III of Ziegenhain, Count Friedrich I of Abenberg [de], Burgrave Friedrich I of Kirchberg [de], Count Heinrich I of Schwarzburg [de], Count Burgrave Burchard von Wartburg, Count Hansteiner of Liechtenstein and Beringer von Wellingen.[7][8]King Henry was said to have survived only because he sat in an alcove with a stone floor[5] and was later saved using ladders. He departed as soon as possible. Landgrave Louis III of Thuringia survived as well.[5]Of those who died, many drowned in human excrement or suffocated from the fumes emitted by the decomposing waste, while others were crushed by falling debris.\n"
str_count()
counts the number of times the pattern appears in the string.
## [1] 3
str_extract()
and str_extract_all()
pull every time the pattern is mentioned in the string.
## [[1]]
## [1] "King" "King" "King"
But this one is a little puzzling; why would we ever need to do this?
12.2 Regular Expressions
The answer is that there are some special codes that we can put into the pattern to return some more complicated results. These are called regular expressions, or regex for short.
These are incredibly powerful, but sometimes a little hard to wrap your mind around. A one simple example is \d, which matches any digit. So we can use this to find every 0-9 in the string.
## [[1]]
## [1] "2" "6" "1" "1" "8" "4" "6" "0" "1" "2" "3" "4" "2" "5" "5" "6" "0" "6" "7" "8" "5" "5"
## [[1]]
## [1] "2" "6" "1" "1" "8" "4" "6" "0" "1" "2" "3" "4" "2" "5" "5" "6" "0" "6" "7" "8" "5" "5"
12.3 Counting Counts
In the middle of this article, we have a list of royalty.
...
including Count Gozmar III of Ziegenhain, Count Friedrich I of Abenberg [de],
Burgrave Friedrich I of Kirchberg [de], Count Heinrich I of Schwarzburg [de],
Count Burgrave Burchard of Wartburg [de], Count Hansteiner of Liechtenstein,
...
As a way to practice regex, let’s build up a way to extract all of these names.
First, we can see that all of this royalty follows a common pattern; an expression that is regular, if you will.
Basically, each one goes:
TITLE Name Sometimes a number of Place
12.3.1 Choices
We can start from the beginning, and get all the titles. With a regex, we can use the ()
parentheses and |
pipe to select any of the possible titles.
## [[1]]
## [1] "Landgrave" "Archbishop" "Count" "Count" "Burgrave" "Count" "Count" "Burgrave" "Count" "Landgrave"
12.3.2 Wildcards
This is a good start! But we need the full title. like \\d
,
there are some other wildcards that can help us get the next parts of the name.
\\w
Matches anything that isn’t a space.
## [[1]]
## [1] "H" "e" "n" "r" "y" "V" "I" "I" "I"
\\s
Matches any kind of white space.
## [1] " "
[ABC]
Matches any of the characters A, B, or C.
## [[1]]
## [1] "V" "I" "I" "I"
So, we can get the next letters by saying TITLE+SPACE+LETTER
## [[1]]
## [1] "Landgrave L" "Archbishop C" "Count G" "Count F" "Burgrave F" "Count H" "Count B" "Count H" "Landgrave L"
Better than before, but we can do better.
12.3.3 Repetition
If you want more than 1 of something in Regex,
?
Matches 0 or 1 of something.+
Matches 1 or more of something.*
Matches 0 or more.{3}
Matches exactly 3 of something{3,}
Matches 3 or more{5,6}
Matches between 5 and 6 of something.
These are super confusing! The best thing to do is just get an example and play around with them.
We can then get the full name of our royalty by doing something TITLE+SPACE+[More than 1 letter]
## [[1]]
## [1] "Landgrave Louis" "Archbishop Conrad" "Count Gozmar" "Count Friedrich" "Burgrave Friedrich" "Count Heinrich" "Count Burgrave" "Count Hansteiner" "Landgrave Louis"
Now, Some of these royals have ordinals after their name, but not all of them! So we will need
to use the *
to capture zero or more roman numerals, like so:
TITLE+SPACE+[More than 1 letter]+[zero or more spaces]+[zero or more roman numerals]
## [[1]]
## [1] "Landgrave Louis III" "Archbishop Conrad " "Count Gozmar III" "Count Friedrich I" "Burgrave Friedrich I" "Count Heinrich I" "Count Burgrave " "Count Hansteiner " "Landgrave Louis III"
Finally, We need the last word, which occurs on all of them. We just add two more words to the regex:
TITLE+SPACE+[More than 1 letter]+[zero or more spaces]+[zero or more roman numerals]+of+[More than 1 letter]
str_extract_all(erfurt, "(Count|Archbishop|Burgrave|Burgmeister|Landgrave)\\s\\w+\\s*[IVXLCDM]*\\sof\\s\\w+")
## [[1]]
## [1] "Landgrave Louis III of Thuringia" "Archbishop Conrad of Mainz" "Count Gozmar III of Ziegenhain" "Count Friedrich I of Abenberg" "Burgrave Friedrich I of Kirchberg" "Count Heinrich I of Schwarzburg"
## [7] "Count Hansteiner of Liechtenstein" "Landgrave Louis III of Thuringia"
And there we have it! All the victims of the Erfurt latrine disaster.
12.4 A Warning
Many people consider Regexes to be “read-only code”; once you’ve written it, you’ll never be able to go back and understand it. You should really only use them when you need to do something very specific.
12.5 Resources
Regexes are hard, and sometimes you might feel like you’re experiencing your own little Erfurt latrine disaster.
Here are a few things that can help you get out of the pit:
A really complete introduction to Regex in R can be found on Stringr documentation here:
https://stringr.tidyverse.org/articles/regular-expressions.html
An interactive console for regexes can be found here:
Note that R is not officially supported here, but you can use Python,
then change all the single backslashes to doubles, and it will mostly work in R (e.g. \d
to \\d
)
12.6 Practice
Here’s the text of a Wikipedia article.
us_history <- read_html("https://en.wikipedia.org/wiki/History_of_the_United_States")
us_history <- us_history |>
html_elements('p') |>
html_text() |>
paste(collapse = " ")
us_history
## [1] "This is an accepted version of this page \n \n\n\n The history of the lands that became the United States began with the arrival of the first people in the Americas around 15,000 BC. After European colonization of North America began in the late 15th century, wars and epidemics decimated Indigenous societies. Starting in 1585, the British colonized the Atlantic Coast, and by the 1760s, the thirteen British colonies were established. The Southern Colonies built an agricultural system on slave labor, enslaving millions from Africa. After defeating France, the British Parliament imposed a series of taxes; resistance to these taxes, especially the Boston Tea Party in 1773, led to Parliament issuing the Intolerable Acts designed to end self-government.\n In 1776, the United States declared its independence. Led by General George Washington, it won the Revolutionary War in 1783. The Constitution was adopted in 1789, and a Bill of Rights was added in 1791 to guarantee inalienable rights. Washington, the first president, and his adviser Alexander Hamilton created a strong central government. The Louisiana Purchase in 1803 doubled the size of the country. Encouraged by available, inexpensive land and the notion of manifest destiny, the country expanded to the Pacific Coast. The resulting expansion of slavery was increasingly controversial, and fueled political and constitutional battles. After the election of Abraham Lincoln as president in 1860, the southern states seceded from the Union to form the pro-slavery Confederate States of America, and started the Civil War. The Confederates' defeat in 1865 led to the abolition of slavery. In the subsequent Reconstruction era, the national government emerged much stronger, and gained explicit duty to protect individual rights. White southern Democrats regained their political power in the South in 1877, often using paramilitary suppression of voting and Jim Crow laws to maintain white supremacy, as well as new state constitutions that legalized racial discrimination.\n The United States became the world's leading industrial power in the 20th century, largely due to entrepreneurship, industrialization, and the arrival of millions of immigrant workers and farmers. A national railroad network was completed, and large-scale mines and factories were established. Dissatisfaction with corruption, inefficiency, and traditional politics stimulated the Progressive movement, leading to reforms including the federal income tax, direct election of Senators, citizenship for many Indigenous people, alcohol prohibition, and women's suffrage. Initially neutral during World War I, the United States declared war on Germany in 1917, joining the successful Allies. After the prosperous Roaring Twenties, the Wall Street Crash of 1929 marked the onset of the decade-long worldwide Great Depression. President Franklin D. Roosevelt's New Deal programs, including unemployment relief and social security, defined modern American liberalism.[1] Following the Japanese attack on Pearl Harbor, the United States entered World War II, helping defeat Nazi Germany and Fascist Italy in the European theater. In the Pacific War, America defeated Imperial Japan after using nuclear weapons on Hiroshima and Nagasaki.\n The United States and the Soviet Union emerged as rival superpowers during the Cold War; the two countries confronted each other indirectly in the arms race, the Space Race, propaganda campaigns, and proxy wars. In the 1960s, in large part due to the civil rights movement, social reforms enforced the constitutional rights of voting and freedom of movement to African Americans. In the 1980s, Ronald Reagan's presidency realigned American politics towards reductions in taxes and regulations. The Cold War ended when the Soviet Union was dissolved in 1991, leaving the United States as the world's sole superpower. Foreign policy after the Cold War has often focused on many conflicts in the Middle East, especially after the September 11 attacks. In the 21st century, the country was negatively affected by the Great Recession and the COVID-19 pandemic.\n It is not definitively known how or when Native Americans first settled the Americas. The prevailing theory proposes that people from Eurasia followed game across Beringia, a land bridge that connected Siberia to present-day Alaska during the Ice Age, and then spread southward. This migration may have begun as early as 30,000 years ago[2] and continued to about 10,000 years ago, when the land bridge became submerged by the rising sea level.[3] These early inhabitants, called Paleo-Indians, soon diversified into hundreds of culturally distinct groups.\n By 10,000 BCE, humans were relatively well-established throughout North America. Originally, Paleo-Indians hunted Ice Age megafauna like mammoths, but as they began to go extinct, people turned instead to bison as a food source, and later foraging for berries and seeds became an important alternative to hunting. Paleo-Indians in central Mexico were the first in the Americas to farm, around 8,000 BCE. Eventually, the knowledge began to spread northward. By 3,000 BCE, corn was being grown in the valleys of Arizona and New Mexico, followed by primitive irrigation systems and, by 300 BCE, early villages of the Hohokam.[4][5] One of the earlier cultures in the present-day United States was the Clovis culture (9,100 to 8,850 BCE), who are primarily identified by the use of fluted spear points called the Clovis point. The Folsom culture was similar, but is marked by the use of the Folsom point.\n A later migration around 8,000 BCE included Na-Dene-speaking peoples, who reached the Pacific Northwest by 5,000 BCE.[6] From there, they migrated along the Pacific Coast and into the interior and constructed large multi-family dwellings in their villages, which were used only seasonally in the summer to hunt and fish, and in the winter to gather food supplies.[7] Another group, the Oshara tradition people, who lived from 5,500 BCE to 600 CE, were part of the Archaic Southwest.\n The Adena began constructing large earthwork mounds around 600 BCE. They are the earliest known people to have been Mound Builders, however, there are mounds in the United States that predate this culture. Watson Brake is an 11-mound complex in Louisiana that dates to 3,500 BCE, and nearby Poverty Point, built by the Poverty Point culture, is an earthwork complex that dates to 1,700 BCE. These mounds likely served a religious purpose.\n The Adenans were absorbed into the Hopewell tradition, a powerful people who traded tools and goods across a wide territory. They continued the Adena tradition of mound-building and pioneered a trading system called the Hopewell Exchange System, which at its greatest extent ran from the present-day Southeast up to the Canadian side of Lake Ontario.[8] By 500 CE, the Hopewellians had been absorbed into the larger Mississippian culture.\n The Mississippians were a broad group of tribes. Their most important city was Cahokia, near modern-day St. Louis, Missouri. At its peak in the 12th century, the city had an estimated population of 20,000, larger than the population of London at the time. The entire city was centered around a mound that stood 100 feet (30 m) tall. Cahokia, like many other cities and villages of the time, depended on hunting, foraging, trading, and agriculture, and developed a class system with slaves and human sacrifice that was influenced by societies to the south, like the Mayans.[4] In the Southwest, the Anasazi began constructing stone and adobe pueblos around 900 BCE.[9] These apartment-like structures were often built into cliff faces, as seen in the Cliff Palace at Mesa Verde. Some grew to be the size of cities, with Pueblo Bonito along the Chaco River in New Mexico once consisting of 800 rooms.[4] The indigenous peoples of the Pacific Northwest were likely the most affluent Native Americans. Many distinct cultural groups and political entities developed there, but they all shared certain beliefs, traditions, and practices, such as the centrality of salmon as a resource and spiritual symbol. Permanent villages began to develop in this region as early as 1,000 BCE, and these communities celebrated by the gift-giving feast of the potlatch.\n In present-day upstate New York, the Iroquois formed a confederacy of tribal peoples in the mid-15th century, consisting of the Oneida, Mohawk, Onondaga, Cayuga, and Seneca.[10][11][12] Each tribe had seats in a group of 50 sachem chiefs. It has been suggested that their culture contributed to political thinking during the development of the United States government.[citation needed] The Iroquois were powerful, waging war with many neighboring tribes, and later, Europeans. As their territory expanded, smaller tribes were forced further west, including the Osage, Kaw, Ponca, and Omaha peoples.[12][13] The exact date for the settling of Hawaii is disputed but the first settlement most likely took place between 940 and 1130 CE.[14] Around 1200 CE, Tahitian explorers found and began settling the area as well establishing a new caste system. This marked the rise of the Hawaiian civilization, which would be largely separated from the rest of the world until the arrival of the British 600 years later.[15][16][17] Europeans under the British explorer James Cook arrived in the Hawaiian Islands in 1778, and within five years of contact, European military technology would help Kamehameha I conquer most of the island group, and eventually unify the islands for the first time, establishing the Hawaiian Kingdom.[18] The island of Puerto Rico has been settled for at least 4,000 years. Starting with the Ortoiroid culture, successive generations of native migrations arrived replacing or absorbing local populations. By the year 1000 Arawak people had arrived from South America via the Lesser Antilles; these settlers would become the Taíno encountered by the Spanish in 1493. Upon European contact a native population between 30,000 and 60,000 was likely, led by a single chief called a Cacique.[19] Colonization resulted in the decimation of the local inhabitants due to the harsh Encomienda system and epidemics caused by Old World diseases. Puerto Rico would remain a part of Spain until American annexation in 1898.[19] The earliest recorded European mention of America is in a historical treatise by the medieval chronicler Adam of Bremen, circa 1075, where it is referred to as Vinland.[a] It is also extensively referred to in the 13th-century Norse Vinland sagas, which relate to events which occurred around 1000. Whilst the strongest archaeological evidence of the existence of Norse settlements in America is located in Canada, most notably at L'Anse aux Meadows and dated to circa 1000, there is significant scholarly debate as to whether Norse explorers also made landfall in New England and other east-coast areas.[21] The Spaniards then rediscovered America in 1492. After a period of exploration sponsored by major European states, the first successful English settlement was established in 1607. Europeans brought horses, cattle, and hogs to the Americas and, in turn, took back maize, turkeys, tomatoes, potatoes, tobacco, beans, and squash to Europe. Many explorers and early settlers died after being exposed to new diseases in the Americas. However, the effects of new Eurasian diseases carried by the colonists, especially smallpox and measles, were much worse for the Native Americans, as they had no immunity to them. They suffered epidemics and died in very large numbers, usually before large-scale European settlement began. Their societies were disrupted and hollowed out by the scale of deaths.[22][23] Spanish explorers were the first Europeans, after the Norse, to reach the present-day United States, after Christopher Columbus's expeditions (beginning in 1492) established possessions in the Caribbean, including the modern-day U.S. territories of Puerto Rico, and parts of the U.S. Virgin Islands. Juan Ponce de León landed in Florida in 1513.[24] Spanish expeditions quickly reached the Appalachian Mountains, the Mississippi River, the Grand Canyon,[25] and the Great Plains.[26] In 1539, Hernando de Soto extensively explored the Southeast,[26] and a year later Francisco Coronado explored from Arizona to central Kansas in search of gold.[26] Escaped horses from Coronado's party spread over the Great Plains, and the Plains Indians mastered horsemanship within a few generations.[4] Small Spanish settlements eventually grew to become important cities, such as San Antonio, Albuquerque, Tucson, Los Angeles, and San Francisco.[27] The Dutch East India Company sent explorer Henry Hudson to search for a Northwest Passage to Asia in 1609. New Netherland was established in 1621 by the company to capitalize on the North American fur trade. Growth was slow at first due to mismanagement by the Dutch and Native American conflicts. After the Dutch purchased the island of Manhattan from the Native Americans for a reported price of US$24, the land was named New Amsterdam and became the capital of New Netherland. The town rapidly expanded and in the mid-1600s it became an important trading center and port. Despite being Calvinists and building the Reformed Church in America, the Dutch were tolerant of other religions and cultures and traded with the Iroquois to the north.[28] The colony served as a barrier to British expansion from New England, and as a result a series of wars were fought. The colony was taken over by Britain as New York in 1664 and its capital was renamed New York City. New Netherland left an enduring legacy on American cultural and political life of religious tolerance and sensible trade in urban areas and rural traditionalism in the countryside (typified by the story of Rip Van Winkle). Notable Americans of Dutch descent include Martin Van Buren, Theodore Roosevelt, Franklin D. Roosevelt, Eleanor Roosevelt and the Frelinghuysens.[28] In the early years of the Swedish Empire, Swedish, Dutch, and German stockholders formed the New Sweden Company to trade furs and tobacco in North America. The company's first expedition was led by Peter Minuit, who had been governor of New Netherland from 1626 to 1631 but left after a dispute with the Dutch government, and landed in Delaware Bay in March 1638. The settlers founded Fort Christina at the site of modern-day Wilmington, Delaware, and made treaties with the indigenous groups for land ownership on both sides of the Delaware River.[29][30] Over the following seventeen years, 12 more expeditions brought settlers from the Swedish Empire (which also included contemporary Finland, Estonia, and portions of Latvia, Norway, Russia, Poland, and Germany) to New Sweden. The colony established 19 permanent settlements along with many farms, extending into modern-day Maryland, Pennsylvania, and New Jersey. It was incorporated into New Netherland in 1655 after a Dutch invasion from the neighboring New Netherland colony during the Second Northern War.[29][30] Giovanni da Verrazzano landed in North Carolina in 1524, and was the first European to sail into New York Harbor and Narragansett Bay. In the 1540s, French Huguenots settled at Fort Caroline near present-day Jacksonville in Florida. In 1565, Spanish forces led by Pedro Menéndez destroyed the settlement and established the first Spanish settlement in what would become the United States — St. Augustine.\n Most French lived in Quebec and Acadia (modern Canada), but far-reaching trade relationships with Native Americans throughout the Great Lakes and Midwest spread their influence. French colonists in small villages along the Mississippi and Illinois rivers lived in farming communities that served as a grain source for Gulf Coast settlements. The French established plantations in Louisiana along with settling New Orleans, Mobile and Biloxi.\n The English, drawn in by Francis Drake's raids on Spanish treasure ships leaving the New World, settled the strip of land along the east coast in the 1600s. The first British colony in North America was established at Roanoke by Walter Raleigh in 1585, but failed. It would be twenty years before another attempt.[4] The early British colonies were established by private groups seeking profit, and were marked by starvation, disease, and Native American attacks. Many immigrants were people seeking religious freedom or escaping political oppression, peasants displaced by the Industrial Revolution, or those simply seeking adventure and opportunity. Between the late 1610s and the Revolution, the British shipped an estimated 50,000 to 120,000 convicts to their American colonies.[31] In some areas, Native Americans taught colonists how to plant and harvest the native crops. In others, they attacked the settlers. Virgin forests provided an ample supply of building material and firewood. Natural inlets and harbors lined the coast, providing easy ports for essential trade with Europe. Settlements remained close to the coast due to this as well as Native American resistance and the Appalachian Mountains that were found in the interior.[4] The first successful English colony, Jamestown, was established by the Virginia Company in 1607 on the James River in Virginia. The colonists were preoccupied with the search for gold and were ill-equipped for life in the New World. Captain John Smith held the fledgling Jamestown together in the first year, and the colony descended into anarchy and nearly failed when he returned to England two years later. John Rolfe began experimenting with tobacco from the West Indies in 1612, and by 1614 the first shipment arrived in London. It became Virginia's chief source of revenue within a decade.\n In 1624, after years of disease and Indian attacks, including the Powhatan attack of 1622, King James I revoked the Virginia Company's charter and made Virginia a royal colony.\n New England was initially settled primarily by Puritans fleeing religious persecution. The Pilgrims sailed for Virginia on the Mayflower in 1620, but were knocked off course by a storm and landed at Plymouth, where they agreed to a social contract of rules in the Mayflower Compact. During the first winter at Plymouth, about half of the Pilgrims died.[32] Like Jamestown, Plymouth suffered from disease and starvation, but local Wampanoag Indians taught the colonists how to farm maize.\n Plymouth was followed by the Puritans and Massachusetts Bay Colony in 1630. They maintained a charter for self-government separate from England, and elected founder John Winthrop as the governor for most of its early years. Roger Williams opposed Winthrop's treatment of Native Americans and religious intolerance, and established the colony of Providence Plantations, later Rhode Island, on the basis of freedom of religion. Other colonists established settlements in the Connecticut River Valley, and on the coasts of present-day New Hampshire and Maine. Native American attacks continued, with the most significant occurring in the 1637 Pequot War and the 1675 King Philip's War.\n New England became a center of commerce and industry due to the poor, mountainous soil making agriculture difficult. Rivers were harnessed to power grain mills and sawmills, and the numerous harbors facilitated trade. Tight-knit villages developed around these industrial centers, and Boston became one of America's most important ports.\n In the 1660s, the Middle Colonies of New York, New Jersey, and Delaware were established in the former Dutch New Netherland, and were characterized by a large degree of ethnic and religious diversity. At the same time, the Iroquois of New York, strengthened by years of fur trading with Europeans, formed the powerful Iroquois Confederacy.\n The last colony in this region was Pennsylvania, established in 1681 by William Penn as a home for religious dissenters, including Quakers, Methodists, and the Amish.[33] The capital of the colony, Philadelphia, became a dominant commercial center in a few short years, with busy docks and brick houses. While Quakers populated the city, German immigrants began to flood into the Pennsylvanian hills and forests, while the Scots-Irish pushed into the far western frontier.\n The overwhelmingly rural Southern Colonies contrasted sharply with the New England and Middle Colonies. After Virginia, the second British colony south of New England was Maryland, established as a Catholic haven in 1632. The economy of these two colonies was built entirely on yeoman farmers and planters. The planters established themselves in the Tidewater region of Virginia, establishing massive plantations with slave labor.\n In 1670, the Province of Carolina was established, and Charleston became the region's great trading port. While Virginia's economy was also based on tobacco, Carolina was more diversified, exporting rice, indigo, and lumber as well. In 1712, it was divided in two, creating North and South Carolina. The Georgia Colony – the last of the Thirteen Colonies – was established by James Oglethorpe in 1732 as a border to Spanish Florida and a reform colony for former prisoners and the poor.[33] Religiosity expanded greatly after the First Great Awakening, a religious revival in the 1740s which was led by preachers such as Jonathan Edwards and George Whitefield. American Evangelicals affected by the Awakening added a new emphasis on divine outpourings of the Holy Spirit and conversions that implanted new believers with an intense love for God. Revivals encapsulated those hallmarks and carried the newly created evangelicalism into the early republic, setting the stage for the Second Great Awakening in the late 1790s.[34] In the early stages, evangelicals in the South, such as Methodists and Baptists, preached for religious freedom and abolition of slavery; they converted many slaves and recognized some as preachers.\n Each of the 13 American colonies had a slightly different governmental structure. Typically, a colony was ruled by a governor appointed from London who controlled the executive administration and relied upon a locally elected legislature to vote on taxes and make laws. By the 18th century, the American colonies were growing very rapidly as a result of low death rates along with ample supplies of land and food. The colonies were richer than most parts of Britain, and attracted a steady flow of immigrants, especially teenagers who arrived as indentured servants.[35] Over half of all European immigrants to Colonial America arrived as indentured servants.[36] Few could afford the cost of the journey to America, and so this form of unfree labor provided a means to immigrate. Typically, people would sign a contract agreeing to a set term of labor, usually four to seven years, and in return would receive transport to America and a piece of land at the end of their servitude. In some cases, ships' captains received rewards for the delivery of poor migrants, and so extravagant promises and kidnapping were common. The Virginia Company and the Massachusetts Bay Company also used indentured servant labor.[4] The first African slaves arrived in 1619.[37] Initially regarded as indentured servants who could buy their freedom, the institution of slavery began to harden and the involuntary servitude became lifelong[37] as the demand for labor on tobacco and rice plantations grew in the 1660s.[citation needed] Slavery became identified with brown skin color, at the time seen as a \"black race\", and the children of slave women were born slaves (partus sequitur ventrem).[37] By the 1770s African slaves comprised a fifth of the American population.\n The question of independence from Britain did not arise as long as the colonies needed British military support against the French and Spanish powers. Those threats were gone by 1765. However, London continued to regard the American colonies as existing for the benefit of the mother country in a policy known as mercantilism.[35] Colonial America was defined by a severe labor shortage that used forms of unfree labor, such as slavery and indentured servitude. The British colonies were also marked by a policy of avoiding strict enforcement of parliamentary laws, known as salutary neglect. This permitted the development of an American spirit distinct from that of its European founders.[38] An upper class emerged in South Carolina and Virginia, with wealth based on large plantations operated by slave labor. A unique class system operated in upstate New York, where Dutch tenant farmers rented land from very wealthy Dutch proprietors, such as the Van Rensselaer family. The other colonies were more egalitarian, with Pennsylvania being representative. By the mid-18th century Pennsylvania was basically a middle-class colony with limited respect for its small upper-class.[39] The French and Indian War (1754–1763), part of the larger Seven Years' War, was a watershed event in the political development of the colonies. The influence of the French and Native Americans, the main rivals of the British Crown in the colonies and Canada, was significantly reduced and the territory of the Thirteen Colonies expanded into New France, both in Canada and Louisiana.[citation needed] The war effort also resulted in greater political integration of the colonies, as reflected in the Albany Congress and symbolized by Benjamin Franklin's call for the colonies to \"Join, or Die.\" Franklin was a man of many inventions – one of which was the concept of a United States of America, which emerged after 1765 and would be realized a decade later.[40] Following Britain's acquisition of French territory in North America, King George III issued the Royal Proclamation of 1763, to organize the new North American empire and protect the Native Americans from colonial expansion into western lands beyond the Appalachian Mountains. In the following years, strains developed in the relations between the colonists and the Crown. The British Parliament passed the Stamp Act of 1765, imposing a tax on the colonies without going through the colonial legislatures. The issue was drawn: did Parliament have the right to tax Americans who were not represented in it? Crying \"No taxation without representation\", the colonists refused to pay the taxes as tensions escalated in the late 1760s and early 1770s.[41] The Boston Tea Party in 1773 was a direct action by activists in the town of Boston to protest against the new tax on tea. Parliament quickly responded the next year with the Intolerable Acts, stripping Massachusetts of its historic right of self-government and putting it under military rule, which sparked outrage and resistance in all thirteen colonies. Patriot leaders from every colony convened the First Continental Congress to coordinate their resistance to the Intolerable Acts. The Congress called for a boycott of British trade, published a list of rights and grievances, and petitioned the king to rectify those grievances.[42] This appeal to the Crown had no effect, though, and so the Second Continental Congress was convened in 1775 to organize the defence of the colonies against the British Army.\n Common people became insurgents against the British even though they were unfamiliar with the ideological rationales being offered. They held very strongly a sense of \"rights\" that they felt the British were deliberately violating – rights that stressed local autonomy, fair dealing, and government by consent. They were highly sensitive to the issue of tyranny, which they saw manifested by the arrival in Boston of the British Army to punish the Bostonians. This heightened their sense of violated rights, leading to rage and demands for revenge, and they had faith that God was on their side.[43] The Second Continental Congress voted to declare independence on July 2, 1776, and the Declaration of Independence was drafted by the Committee of Five. The Declaration of Independence presented arguments in favor of the rights of citizens, stating that all men are created equal, supporting the rights of Life, Liberty and the pursuit of Happiness, and demanding the consent of the governed. It also listed grievances against the crown.[44] The Founding Fathers were guided by the ideology of republicanism, rejecting the monarchism of Great Britain.[45] The Declaration of Independence was signed by members of the Congress on July 4.[44] This date has since been commemorated as Independence Day.[46] The American Revolutionary War began with the Battles of Lexington and Concord when American and British forces clashed on April 19, 1775.[47]George Washington was appointed general of the Continental Army.[48] The New York and New Jersey campaign was the first major campaign of the war, beginning in 1776. Washington's crossing of the Delaware River began a series of victories that expelled British forces from New Jersey.[49] The British began the Saratoga campaign in 1777 to capture Albany, New York, as a choke point.[50] After American victory at Saratoga, France, the Netherlands, and Spain began providing support to the Continental Army.[51] Britain responded to defeat in the northern theater by advancing in the southern theater, beginning with the Capture of Savannah in 1778.[52] American forces reclaimed the south in 1781, and the British Army was defeated in the Siege of Yorktown on October 19, 1781.[53] King George III formally ordered the end of hostilities on December 5, 1782, recognizing American independence.[54] The Treaty of Paris was negotiated between Great Britain and the United States to establish terms of peace. It was signed on September 3, 1783,[55] and it was ratified by the Congress of the Confederation on January 14, 1784.[56] Washington resigned his commission as commander-in-chief of the Continental Army on December 23, 1783.[57] The Articles of Confederation were ratified as the governing law of the United States, written to limit the powers of the central government in favor of state governments. This caused economic decline, as the government was unable to pass economic legislation and pay its debts.[58] Nationalists worried that the confederate nature of the union was too fragile to withstand an armed conflict with any adversarial states, or even internal revolts such as the Shays' Rebellion of 1786 in Massachusetts.[59]\nIn the 1780s the national government was able to settle the issue of the western regions of the young United States, which were ceded by the states to Congress and became territories. With the migration of settlers to the Northwest, soon they became states.[59] The American Indian Wars continued in the 1780s as settlers moved west, prompting Native American attacks on American civilians and in turn prompting American attacks on Native American civilians.[60] The Northwestern Confederacy and American settlers began fighting the Northwest Indian War in the late 1780s; the Northwestern Confederacy received British support, but the settlers received little assistance from the American government.[61][62] Nationalists – most of them war veterans – organized in every state and convinced Congress to call the Philadelphia Convention in 1787. The delegates from every state wrote a new Constitution that created a federal government with a strong president and powers of taxation. The new government reflected the prevailing republican ideals of guarantees of individual liberty and of constraining the power of government through a system of separation of powers.[59] A national debate took place over whether the constitution should be ratified, and it was ratified by a sufficient number of states in 1788 to begin forming a federal government.[63] The United States Electoral College chose George Washington as the first President of the United States in 1789.[64] George Washington became the first president of the United States under the new Constitution in 1789. The national capital moved from New York to Philadelphia in 1790 and finally settled in Washington, D.C., in 1800.\n The major accomplishment of the Washington Administration was creating a strong national government that was recognized without question by all Americans.[65] His government, following the vigorous leadership of Treasury Secretary Alexander Hamilton, assumed the debts of the states (the debt holders received federal bonds), created the Bank of the United States to stabilize the financial system, and set up a uniform system of tariffs (taxes on imports) and other taxes to pay off the debt and provide a financial infrastructure. To support his programs Hamilton created a new political party – the first in the world based on voters[vague] – the Federalist Party.\n To assuage the Anti-Federalists who feared a too-powerful central government, the Congress adopted the United States Bill of Rights in 1791. Comprising the first ten amendments of the Constitution, it guaranteed individual liberties such as freedom of speech and religious practice, jury trials, and stated that citizens and states had reserved rights (which were not specified).[66] Thomas Jefferson and James Madison formed an opposition Republican Party (usually called the Democratic-Republican Party by political scientists). Hamilton and Washington presented the country in 1794 with the Jay Treaty that reestablished good relations with Britain. The Jeffersonians vehemently protested, and the voters aligned behind one party or the other, thus setting up the First Party System. Federalists promoted business, financial and commercial interests and wanted more trade with Britain. Republicans accused the Federalists of plans to establish a monarchy, turn the rich into a ruling class, and making the United States a pawn of the British.[67] The treaty passed, but politics became intensely heated.[68] Serious challenges to the new federal government included the Northwest Indian War, the ongoing Cherokee–American wars, and the 1794 Whiskey Rebellion, in which western settlers protested against a federal tax on liquor. Washington called the state militia and personally led an army against the settlers, as the insurgents melted away and the power of the federal government was firmly established.[69] Washington refused to serve more than two terms – setting a precedent – and in his famous farewell address, he extolled the benefits of federal government and importance of ethics and morality while warning against foreign alliances and the formation of political parties.[70] John Adams, a Federalist, defeated Jefferson in the 1796 election. War loomed with France and the Federalists used the opportunity to try to silence the Republicans with the Alien and Sedition Acts, build up a large army with Hamilton at the head, and prepare for a French invasion. However, the Federalists became divided after Adams sent a successful peace mission to France that ended the Quasi-War of 1798.[67][71] During the first two decades after the Revolutionary War, there were dramatic changes in the status of slavery among the states and an increase in the number of freed blacks. Inspired by revolutionary ideals of the equality of men and influenced by their lesser economic reliance on slavery, northern states abolished slavery.\n States of the Upper South made manumission easier, resulting in an increase in the proportion of free blacks in the Upper South (as a percentage of the total non-white population) from less than one percent in 1792 to more than 10 percent by 1810. By that date, a total of 13.5 percent of all blacks in the United States were free.[72] In 1807, with four million slaves already in the United States, Congress severed the U.S.'s involvement with the Atlantic slave trade. For 50 of the country's first 72 years, a slaveholder served as president, and during that period, only slaveholding presidents were re-elected to second terms.[73] The Second Great Awakening was a Protestant revival movement that affected virtually all of society during the early 19th century and led to rapid church growth. The movement began around 1790, gained momentum by 1800, and, after 1820 membership rose rapidly among Baptist and Methodist congregations, whose preachers led the movement. It was past its peak by the 1840s.[74] It enrolled millions of new members in existing evangelical denominations and led to the formation of new denominations. Many converts believed that the Awakening heralded a new millennial age. The Second Great Awakening stimulated the establishment of many reform movements – including abolitionism and temperance designed to remove the evils of society before the anticipated Second Coming of Jesus Christ.[75] Jefferson defeated Adams massively for the presidency in the 1800 election. Jefferson's major achievement as president was the Louisiana Purchase in 1803, which provided U.S. settlers with vast potential for expansion west of the Mississippi River.[76]\nJefferson, a scientist, supported expeditions to explore and map the new domain, most notably the Lewis and Clark Expedition.[77] Jefferson believed deeply in republicanism and argued it should be based on the independent yeoman farmer and planter; he distrusted cities, factories and banks. He also distrusted the federal government and judges, and tried to weaken the judiciary. However he met his match in John Marshall, a Federalist from Virginia. Although the Constitution specified a Supreme Court, its functions were vague until Marshall, the Chief Justice of the United States (1801–1835), defined them, especially the power to overturn acts of Congress or states that violated the Constitution, first enunciated in 1803 in Marbury v. Madison.[78] Americans were increasingly angry at the British violation of American ships' neutral rights to hurt France, the impressment (seizure) of 10,000 American sailors needed by the Royal Navy to fight Napoleon, and British support for hostile Indians attacking American settlers in the American Midwest with the goal of creating a pro-British Indian barrier state to block American expansion westward. They may also have desired to annex all or part of British North America, although this is still heavily debated.[79][80][81][82][83] Despite strong opposition from the Northeast, especially from Federalists who did not want to disrupt trade with Britain, Congress declared war on June 18, 1812.[84] The war was frustrating for both sides. Both sides tried to invade the other and were repulsed. The American high command remained incompetent until the last year. The American militia proved ineffective because the soldiers were reluctant to leave home and efforts to invade Canada repeatedly failed. The British blockade ruined American commerce, bankrupted the Treasury, and further angered New Englanders, who smuggled supplies to Britain. The Americans under General William Henry Harrison finally gained naval control of Lake Erie and defeated the Indians under Tecumseh in Canada,[86] while Andrew Jackson ended the Indian threat in the Southeast. The Indian threat to expansion into the Midwest was permanently ended. The British invaded and occupied much of Maine.\n The British raided and burned Washington, but were repelled at Baltimore in 1814 – where the \"Star Spangled Banner\" was written to celebrate the American success. In upstate New York a major British invasion of New York State was turned back at the Battle of Plattsburgh. Finally in early 1815 Andrew Jackson decisively defeated a major British invasion at the Battle of New Orleans, making him the most famous war hero.[87] With Napoleon (apparently) gone, the causes of the war had evaporated and both sides agreed to a peace that left the prewar boundaries intact. Americans claimed victory on February 18, 1815, as news came almost simultaneously of Jackson's victory of New Orleans and the peace treaty that left the prewar boundaries in place. Americans swelled with pride at success in the \"second war of independence\"; the naysayers of the antiwar Federalist Party were put to shame and the party never recovered. This helped lead to an emerging American identity that cemented national pride over state pride.[88] Britain never achieved the war goal of granting the Indians a barrier state to block further American settlement and this allowed settlers to pour into the Midwest without fear of a major threat.[87] The War of 1812 also destroyed America's negative perception of a standing army, which had proven useful in many areas against the British as opposed to ill-equipped and poorly-trained militias in the early months of the war, and War Department officials instead decided to place regular troops as the main military capabilities of the government.[89] As strong opponents of the War of 1812, the Federalists held the Hartford Convention in 1814 that hinted at disunion. National euphoria after the victory at New Orleans ruined the prestige of the Federalists and they no longer played a significant role as a political party.[90] President Madison and most Republicans realized they were foolish to let the First Bank of the United States close down, for its absence greatly hindered the financing of the war. So, with the assistance of foreign bankers, they chartered the Second Bank of the United States in 1816.[91][92] The Republicans also imposed tariffs designed to protect the infant industries that had been created when Britain was blockading the U.S. With the collapse of the Federalists as a party, the adoption of many Federalist principles by the Republicans, and the systematic policy of President James Monroe in his two terms (1817–1825) to downplay partisanship, society entered an Era of Good Feelings, with far less partisanship than before (or after), and closed out the First Party System.[91][92] The Monroe Doctrine, expressed in 1823, proclaimed the United States' opinion that European powers should no longer colonize or interfere in the Americas. This was a defining moment in the foreign policy of the United States. The Monroe Doctrine was adopted in response to American and British fears over Russian and French expansion into the Western Hemisphere.[93] In 1832, President Andrew Jackson, 7th President of the United States, ran for a second term under the slogan \"Jackson and no bank\" and did not renew the charter of the Second Bank, dissolving the bank in 1836.[94] Jackson was convinced that central banking was used by the elite to take advantage of the average American, and instead implemented publicly owned banks in various states, popularly known as \"pet banks\".[94] After the First Party System of Federalists and Republicans withered away in the 1820s, the stage was set for the emergence of a new party system based on well organized local parties that appealed for the votes of (almost) all adult white men. The former Jeffersonian (Democratic-Republican) party split into factions. They split over the choice of a successor to President James Monroe, and the party faction that supported many of the old Jeffersonian principles, led by Andrew Jackson and Martin Van Buren, became the Democratic Party. As Norton explains the transformation in 1828:\n Jacksonians believed the people's will had finally prevailed. Through a lavishly financed coalition of state parties, political leaders, and newspaper editors, a popular movement had elected the president. The Democrats became the nation's first well-organized national party, and tight party organization became the hallmark of nineteenth-century American politics.[95] Opposing factions led by Henry Clay helped form the Whig Party. The Democratic Party had a small but decisive advantage over the Whigs until the 1850s, when the Whigs fell apart over the issue of slavery.\n The American colonies and the newly formed union grew rapidly in population and area, as pioneers pushed the frontier of settlement west.[96][97] The process finally ended around 1890–1912 as the last major farmlands and ranch lands were settled. Native American tribes in some places resisted militarily, but they were overwhelmed by settlers and the army, and after 1830, were relocated to reservations in the west.[98] That year, Congress passed the Indian Removal Act, which authorized the president to negotiate treaties that exchanged Native American tribal lands in the eastern states for lands west of the Mississippi River.[99] Its goal was primarily to remove Native Americans, including the Five Civilized Tribes, from the American Southeast – they occupied land that settlers wanted.[100] Jacksonian Democrats demanded the forcible removal of native populations who refused to acknowledge state laws to reservations in the West. Whigs and religious leaders opposed the move as inhumane. Thousands of deaths resulted from the relocations, as seen in the Cherokee Trail of Tears.[100] The Trail of Tears resulted in approximately 2,000 to 8,000 of the 16,543 relocated Cherokee dying along the way.[101][102] Many of the Seminole Indians in Florida refused to move west, and fought the Army for years in the Seminole Wars.\n The first settlers in the west were the Spanish in New Mexico (\"Californios\"), followed by over 100,000 California Gold Rush miners ('49ers). California grew rapidly, and by 1880, San Francisco had become the economic hub of the entire Pacific Coast, with a diverse population of a quarter million. From the early 1830s to 1869, the Oregon Trail and its many offshoots were used by over 300,000 settlers. '49ers, ranchers, farmers, entrepreneurs, and their families headed to California, Oregon, and other points in the far west. Wagon-trains took five or six months on foot.[103] Manifest destiny was the belief that American settlers were destined to expand across the continent. This concept was born out of \"A sense of mission to redeem the Old World by high example ... generated by the potentialities of a new earth for building a new heaven\".[104] Manifest destiny was rejected by modernizers, especially the Whigs like Henry Clay and Abraham Lincoln who wanted to build cities and factories – not more farms.[b]Democrats strongly favored expansion, and won the key election of 1844. After a bitter debate in Congress, the Republic of Texas was annexed in 1845, leading to war with Mexico, who considered Texas to be a part of Mexico due to the large numbers of Mexican settlers.[106] The Mexican–American War broke out in 1846, with the Whigs opposed to the war, and the Democrats supporting it. The U.S. Army, using regulars and large numbers of volunteers, defeated the Mexican armies, invaded at several points, captured Mexico City, and won decisively. The Treaty of Guadalupe Hidalgo ended the war in 1848. Many Democrats wanted to annex all of Mexico, but that idea was rejected by White Southerners, who argued that by incorporating millions of Mexican people, mainly of mixed race, would undermine the U.S. as an exclusively white republic.[105] Instead, the U.S. took Texas and the lightly settled northern parts (California and New Mexico). The Hispanic residents were given full citizenship, and the Mexican Indians became American Indians. Simultaneously, gold was discovered in California in 1848. To clear the state for settlers, the U.S. government began a policy of extermination since termed the California genocide.[107] A peaceful compromise with Britain gave the U.S. ownership of the Oregon Country, which was renamed the Oregon Territory.[106] The demand for guano (prized as an agricultural fertilizer) led the U.S. to pass the Guano Islands Act in 1856, which enabled U.S. citizens to take possession, in the name of the country, of unclaimed islands containing guano deposits. Under the act, the U.S. annexed nearly 100 islands in the Pacific Ocean and the Caribbean Sea. By 1903, 66 of these islands were recognized as territories of the United States.[108] The women's suffrage movement began with the 1848 National Convention of the Liberty Party. Presidential candidate Gerrit Smith argued for and established women's suffrage as a party goal. One month later, the Seneca Falls Convention was organized, signing the Declaration of Sentiments demanding equal rights for women, including the right to vote.[c] Many of these activists became politically aware during the abolitionist movement. The women's rights campaign during first-wave feminism was led by Elizabeth Cady Stanton, Lucy Stone and Susan B. Anthony, among others. Stone and Paulina Wright Davis organized the prominent and influential National Women's Rights Convention in 1850.[110] The central issue after 1848 was the expansion of slavery, with the anti-slavery elements in the North pitted against the pro-slavery elements in the South.[111] By 1860, there were four million slaves in the South, nearly eight times as many as there were nationwide in 1790.[citation needed] A small number of active Northerners were abolitionists who followed William Lloyd Garrison, and declared that ownership of slaves was a sin and demanded its immediate abolition. Much larger numbers in the North were against the expansion of slavery, seeking to put it on the path to extinction so that America would be committed to free land (as in low-cost farms owned and cultivated by a family), free labor, and free speech (as opposed to censorship of abolitionist material in the South).[111] However, before 1860, only a minority of Northern white people supported abolition, which was often seen as a 'radical' measure. There were violent reactions to abolitionist advocates in the North, notably the burning of an anti-slavery society in Pennsylvania Hall.[112] There was resistance to slavery by both peaceful and violent means. Slave rebellions, by Gabriel Prosser (1800), Denmark Vesey (1822), Nat Turner (1831), and John Brown (1859) caused fear in the white South, which imposed stricter oversight of slaves and reduced the rights of free Black people.[citation needed] Former slaves Frederick Douglass and Harriet Tubman became leading advocates for abolition.[113][114] The issue was discussed in the best-selling anti-slavery novel Uncle Tom's Cabin by Harriet Beecher Stowe.[115] Southern white Democrats insisted that slavery was of economic, social, and cultural benefit to all white people and even to the slaves themselves.[111] Justifications of slavery included history, religion, legality, social good, and economics. Defenders argued that the sudden end to the slave economy would have had a fatal economic impact in the South, and there would be widespread unemployment and chaos; slave labor was the foundation of their economy.[116] Southern slavery-based societies had become wealthy based on their cotton and other agricultural commodity production, as well as the internal slave trade. The plantations were highly profitable, due to the heavy European demand for raw cotton. Northern cities and regional industries were tied economically to slavery by banking, shipping, and manufacturing, including textile mills. In addition, southern states benefited by their increased apportionment in Congress due to the partial counting of slaves in their populations.\n Religious activists were split on slavery, with the Methodists and Baptists dividing into northern and southern denominations. In the North, the Methodists, Congregationalists, and Quakers included many abolitionists, especially among women activists. The Catholic, Episcopal, and Lutheran denominations largely ignored the issue.[117] The issue of slavery in the new territories was seemingly settled by the Compromise of 1850, brokered by Whig Henry Clay and Democrat Stephen Douglas; the Compromise included the admission of California as a free state in exchange for no federal restrictions on slavery placed on Utah or New Mexico.[118] A point of contention was the Fugitive Slave Act, which required the states to cooperate with slave owners when attempting to recover escaped slaves. Formerly, an escaped slave that reached a non-slave state was presumed to have attained sanctuary and freedom under the Missouri Compromise.[119][120][115] The Compromise of 1820 was repealed in 1854 with the Kansas–Nebraska Act, promoted by Stephen Douglas in the name of \"popular sovereignty\" and democracy. It permitted voters to decide on the legality of slavery in each territory, and allowed Douglas to adopt neutrality on the issue of slavery. Anti-slavery forces rose in anger and alarm, forming the new Republican Party. Pro- and anti- contingents rushed to Kansas to vote for or against slavery, resulting in a miniature civil war called Bleeding Kansas. By the late 1850s, the young Republican Party dominated nearly all northern states, and thus, the electoral college. It insisted that slavery would never be allowed to expand, and thus would slowly die out.[121] The Supreme Court's 1857 decision in Dred Scott v. Sandford ruled that the Compromise was unconstitutional and that free Black people were not U.S. citizens; the decision enraged Northerners. The Republicans worried the decision could be used to expand slavery throughout all states and territories. With Senator Abraham Lincoln leading criticism of the ruling, the stage was set for the 1860 presidential election.[119][120][115] After Abraham Lincoln won the 1860 election, seven Southern states seceded from the Union in the first of two waves of secession and formed a sovereign state, the Confederate States of America (Confederacy), on February 8, 1861.[122] The Civil War began on April 12, 1861, when Confederate forces attacked a U.S. military installation at Fort Sumter in South Carolina. In response, Lincoln called on the states to send troops to recapture forts, protect Washington D.C., and \"preserve the Union,\" which in his view still existed despite the secession.[123] Lincoln's call led to four more states seceding in a second wave of secession and joining the Confederacy. A few of the (northernmost) slave states did not secede and became known as the border states; these were Delaware, Maryland, Kentucky, and Missouri.[citation needed] During the war, the northwestern portion of Virginia seceded from the Confederacy, which became the new Union state of West Virginia.[124] The two armies' first major battle was the First Battle of Bull Run, which proved to both sides that the war would be much longer than anticipated.[123] In the western theater, the Union Army was relatively successful, with major battles such as Perryville and Shiloh, along with Union Navy gunboat dominance of navigable rivers producing strategic Union victories and destroying major Confederate operations.[125] Warfare in the eastern theater began poorly for the Union. U.S. General George B. McClellan failed to capture the Confederate capital of Richmond, Virginia, in his Peninsula campaign and retreated after attacks from Confederate General Robert E. Lee.[126] Meanwhile, in 1861 and 1862, both sides concentrated on raising and training new armies. The Union successfully gained control of the border states, driving the Confederates out.[127] The autumn 1862 Confederate retreat at the Battle of Antietam led to Lincoln's warning he would issue the Emancipation Proclamation in January 1863 if the states did not return. Making slavery a central war goal energized Northern Republicans, as well as their enemies, the anti-war Copperhead Democrats. It ended the chance of British and French intervention.[127] Lee's smaller Army of Northern Virginia won battles in late 1862 and spring 1863, but he pushed too hard and ignored the Union threat in the west. He invaded Pennsylvania in search of supplies and to cause war-weariness in the North.[128] The Emancipation Proclamation was an executive order issued by Lincoln on January 1, 1863. It freed 3 million slaves in designated areas of the Confederacy. The owners were not compensated. Plantation owners, realizing that emancipation would destroy their economic system, sometimes moved their slaves as far as possible from the Union army.[130] In perhaps the turning point of the war, Lee's army was badly beaten by the Army of the Potomac at the July 1863 Battle of Gettysburg, and barely made it back to Virginia.[127] Survivors of the battle were immediately redeployed to suppress the New York City draft riots by Irish Americans protesting Civil War conscription and the city's free Black population.[128] In July 1863, Union forces under General Ulysses S. Grant gained control of the Mississippi River at the Battle of Vicksburg, thereby splitting the Confederacy. In 1864, Union General William Tecumseh Sherman marched south from Chattanooga to capture Atlanta, a decisive victory that ended war jitters among Republicans in the North and helped Lincoln win re-election.\n The Civil War was the world's earliest industrial war. Railroads, the telegraph, steamships, and mass-produced weapons were employed extensively. Civilian factories, mines, shipyards, and were mobilized.[131] Foreign trade increased, with the U.S. providing both food and cotton to Britain, and Britain sending in manufactured products and thousands of volunteers for the Union Army (and a few to the Confederate army). The Union blockade shut down Confederate ports, and by late 1864, the British blockade runners supplying Confederates were usually captured before they could make more than a handful of runs.\n Sherman's march to the sea was almost unopposed, and demonstrated that the South was unable to resist a Union invasion. Much of the South was destroyed, and could no longer provide desperately needed supplies to its armies. In spring 1864, Grant launched a war of attrition and pursued Lee to the final Appomattox campaign, which resulted in Lee surrendering in April 1865.[citation needed] By June 1865, the Union Army controlled all of the Confederacy and liberated all of the designated slaves.[130] It remains the deadliest war in American history, resulting in the deaths of about 750,000 soldiers and an undetermined number of civilian casualties.[d] About ten percent of all Northern males 20–45 years old, and thirty percent of all Southern white males aged 18–40 died.[131] Northern military deaths were greater than Southern military deaths in absolute numbers, but were two-thirds smaller in terms of proportion of the population affected. Many Black people died after being dislocated during the war and Reconstruction.[134] Reconstruction lasted from the end of the war until 1877.[123][135][136] Lincoln had to decide the statuses of the ex-slaves (\"Freedmen\"), ex-Confederates, and ex-Confederate states. He supported the Ten Percent Plan for states' re-admission, and the right of Black people to vote.[137] Lincoln was assassinated in April 1865 by John Wilkes Booth, and succeeded by Andrew Johnson.[138] The severe threats of starvation and displacement of the unemployed Freedmen were met by the first major federal relief agency, the Freedmen's Bureau, operated by the Army.[139] The bureau also took in freed slaves.[citation needed] Three \"Reconstruction Amendments\" expanded civil rights for black Americans: the 1865 Thirteenth Amendment outlawed slavery;[140] the 1868 Fourteenth Amendment guaranteed equal rights for all and citizenship for Black people;[141] the 1870 Fifteenth Amendment prevented race from being used to disenfranchise men.[142] Ex-Confederates remained in control of most Southern states for over two years, until the Radical Republicans gained control of Congress in the 1866 elections. Johnson, who sought good treatment for ex-Confederates, was virtually powerless in the face of Congress; he was impeached, but the Senate's attempt to remove him from office failed by one vote. Congress enfranchised black men and temporarily banned many ex-Confederate leaders from holding office. New Republican governments came to power based on a coalition of Freedmen made up of Carpetbaggers (new arrivals from the North), and Scalawags (native white Southerners). They were backed by the Army. Opponents said they were corrupt and violated the rights of whites.[143] After the war, the far west was developed and settled, first by wagon trains and riverboats, and then by the first transcontinental railroad. Many Northern European immigrants took up low-cost or free farms in the Prairie States. Mining for silver and copper encouraged development.[144] State by state, the New Republicans lost power to a conservative-Democratic coalition, which gained control of the South by 1877. In response to Radical Reconstruction, the Ku Klux Klan (KKK) emerged in 1867 as a white-supremacist organization opposed to black civil rights and Republican rule. President Ulysses Grant's enforcement of the Ku Klux Klan Act of 1870 shut them down.[143] Paramilitary groups, such as the White League and Red Shirts emerging around 1874, openly intimidated and attacked Black people voting, to regain white political power in states across the South. One historian described them as the military arm of the Democratic Party.[143] Reconstruction ended after the disputed 1876 election. The Compromise of 1877 gave Republican candidate Rutherford B. Hayes the presidency in exchange for removing all remaining federal troops in the South. The federal government withdrew its troops, and Southern Democrats took control of the region[145] In 1882, the United States passed the Chinese Exclusion Act (which barred all Chinese immigrants except for students and businessmen),[146] and the Immigration Act of 1882 (which barred all immigrants with mental health issues).[147] From 1890 to 1908, southern states effectively disenfranchised Black and poor white voters by making voter registration more difficult through poll taxes and literacy tests. Black people were segregated from whites in the violently-enforced Jim Crow system that lasted until roughly 1968.[148][149] The \"Gilded Age\" was a term that Mark Twain used to describe the period of the late 19th century with a dramatic expansion of American wealth and prosperity, underscored by the mass corruption in the government.[151] Some historians have argued that the United States was effectively plutocratic for at least part of the Gilded Age and Progressive Era.[152][153][154] As financiers and industrialists such as J.P. Morgan and John D. Rockefeller began to amass vast fortunes, many observers were concerned that the nation was losing its pioneering egalitarian spirit.[155] An unprecedented wave of immigration from Europe served to both provide the labor for American industry and create diverse communities in previously undeveloped areas. From 1880 to 1914, peak years of immigration, more than 22 million people migrated to the country.[156] By 1890, American industrial production and per capita income exceeded those of all other countries.[citation needed] Most were unskilled workers who quickly found jobs in mines, mills, and factories. Many immigrants were craftsmen and farmers (especially from Britain, Germany, and Scandinavia) who purchased inexpensive land on the prairies. Poverty, growing inequality and dangerous working conditions, along with socialist and anarchist ideas diffusing from European immigrants, led to the rise of the labor movement.[157][158][159] Dissatisfaction on the part of the growing middle class with the corruption and inefficiency of politics, and the failure to deal with increasingly important urban and industrial problems, led to the dynamic progressive movement starting in the 1890s. In every major city, and at the federal level, progressives called for the modernization and reform of decrepit institutions in the fields of politics, education, medicine, and industry.[160] Leading politicians from both parties, most notably Republicans Theodore Roosevelt, Charles Evans Hughes, and Robert La Follette, and Democrats William Jennings Bryan and Woodrow Wilson, took up the cause of progressive reform.[160]\"Muckraking\" journalists such as Upton Sinclair, Lincoln Steffens and Jacob Riis exposed corruption in business and government, and highlighted rampant inner-city poverty. Progressives implemented antitrust laws and regulated such industries of meat-packing, drugs, and railroads. Four new constitutional amendments – the Sixteenth through Nineteenth – resulted from progressive activism, bringing the federal income tax, direct election of Senators, prohibition, and female suffrage.[160] In 1881, President James A. Garfield was assassinated by Charles Guiteau.[161] Skilled workers banded together to control their crafts and raise wages by forming labor unions in industrial areas of the Northeast. Samuel Gompers led the American Federation of Labor (1886–1924), coordinating multiple unions. In response to heavy debts and decreasing farm prices, wheat and cotton farmers joined the Populist Party.[162] The Panic of 1893 broke out, and created a severe nationwide depression impacted farmers, workers, and businessmen.[163] Many railroads went bankrupt. The resultant political reaction fell on the Democratic Party, whose leader President Grover Cleveland shouldered much of the blame. Labor unrest involved numerous strikes, most notably the violent Pullman Strike of 1894, which was forcibly shut down by federal troops under Cleveland's orders. One of the disillusioned leaders of the Pullman strike, Eugene V. Debs, went on to become the leader of the Socialist Party of America, eventually going on to win almost 1 million votes in the 1912 presidential election.[164] Important legislation of the era included the 1883 Civil Service Act, which mandated a competitive examination for applicants for government jobs, the 1887 Interstate Commerce Act, which ended railroads' discrimination against small shippers, and the 1890 Sherman Antitrust Act, which outlawed monopolies in business.[151] After 1893, the Populist Party gained strength among farmers and coal miners, but was overtaken by the even more popular Free silver movement, which demanded using silver to enlarge the money supply, leading to inflation that the silverites promised would end the depression.[165] Financial and railroad communities fought back hard, arguing that only the gold standard would save the economy. In the 1896 presidential election, conservative Republican William McKinley defeated silverite William Jennings Bryan, who ran on the Democratic, Populist, and Silver Republican tickets. Bryan swept the South and West, but McKinley ran up landslides among the middle class, industrial workers, cities, and among upscale farmers in the Midwest.[166] Prosperity returned under McKinley. The gold standard was enacted, and the tariff was raised. By 1900, the U.S. had the strongest economy in the world. Republicans, citing McKinley's policies, took the credit for the growth.[167] McKinley was assassinated by Leon Czolgosz in 1901, and was succeeded by Theodore Roosevelt.[168] The period also saw a major transformation of the banking system, with the arrival of the first credit union in 1908 (and thus, cooperative banking) and the creation of the Federal Reserve System in 1913.[169][170] Apart from two short recessions in 1907 and 1920, the economy remained prosperous and growing until 1929.[167] The United States Army continued to fight wars with Native Americans as settlers encroached on their traditional lands. Gradually the U.S. purchased the Native American tribal lands and extinguished their claims, forcing most tribes onto subsidized reservations. According to the U.S. Census Bureau in 1894, from 1789 to 1894, the Indian Wars killed 19,000 white people and more than 30,000 Indians.[172] The United States emerged as a world economic and military power after 1890. The main episode was the Spanish–American War, which began when Spain refused American demands to reform its oppressive policies in Cuba.[173] The war was a series of quick American victories on land and at sea. At the Treaty of Paris peace conference the United States acquired the Philippines, Puerto Rico, and Guam.[174] Cuba became an independent country, under close American tutelage. Although the war itself was widely popular, the peace terms proved controversial. William Jennings Bryan led his Democratic Party in opposition to control of the Philippines, which he denounced as imperialism unbecoming to American democracy.[174] President William McKinley defended the acquisition and was riding high as society had returned to prosperity and felt triumphant in the war. McKinley easily defeated Bryan in a rematch in the 1900 presidential election.[175] After defeating an insurrection by Filipino nationalists, the United States achieved little in the Philippines except in education, and it did something in the way of public health. It also built roads, bridges, and wells, but infrastructural development lost much of its early vigor with the failure of the railroads.[176] By 1908, however, Americans lost interest in an empire and turned their international attention to the Caribbean, especially the building of the Panama Canal. The canal opened in 1914 and increased trade with Japan and the rest of the Far East. A key innovation was the Open Door Policy, whereby the imperial powers were given equal access to Chinese business, with not one of them allowed to take control of China.[177] The women's suffrage movement reorganized after the Civil War, gaining experienced campaigners, many of whom had worked for prohibition in the Women's Christian Temperance Union. By the end of the century, a few Western states had granted women full voting rights,[110] and women gained rights in areas such as property and child custody law.[178] Around 1912, the feminist movement reawakened, putting an emphasis on its demands for equality, and arguing that the corruption of American politics demanded purification by women.[179] Protests became increasingly common, as suffragette Alice Paul led parades through the capital and major cities. Paul split from the large, moderate National American Woman Suffrage Association (NAWSA) led by Carrie Chapman Catt, and formed the more militant National Woman's Party. Suffragists were arrested during their \"Silent Sentinels\" pickets at the White House, and were taken as political prisoners.[180] Another prominent leader of the movement was Jane Addams of Chicago, who created settlement houses.[160] The anti-suffragist argument that only men could fight in a war, and therefore only men deserve the right to vote, was refuted by the participation of American women on the home front in World War I. The success of woman's suffrage was demonstrated by the politics of states which already allowed women to vote, including Montana, who elected the first woman to the House of Representatives, Jeannette Rankin. The main resistance came from the South, where white leaders were worried about the threat of Black women voting. Congress passed the Nineteenth Amendment in 1919, and women could vote in 1920.[182] NAWSA became the League of Women Voters. Politicians responded to the new electorate by emphasizing issues of special interest to women, especially prohibition, child health, and world peace.[183][184] Notably, in 1928, women were mobilized to support both candidates in the year's presidential election between Al Smith and Herbert Hoover.[185] As World War I raged in Europe from 1914, President Woodrow Wilson took full control of foreign policy, declaring neutrality, but warning Germany that resumption of unrestricted submarine warfare against American ships supplying goods to Allied nations would mean war. Germany decided to take the risk, and try to win by cutting off supplies to Britain through the sinking of ships such as the RMS Lusitania. The U.S. declared war in April 1917, mainly from the threat of the Zimmermann Telegram.[186] By the summer of 1918 soldiers in General John J. Pershing's American Expeditionary Forces arrived at the rate of 10,000 a day, while Germany was unable to replace its losses.[187] Dissent against the war was suppressed by the Sedition Act of 1918 & Espionage Act of 1917. German language, leftist & pacifist publications were suppressed. Over 2,000 were imprisoned for speaking out against the war, later released by U.S. President Warren G. Harding.[188] The Allies won in November 1918. Wilson demanded Germany depose Wilhelm II and accept his terms in the famed Fourteen Points speech. Wilson dominated the 1919 Paris Peace Conference, putting his geopolitical hopes in the new League of Nations as Germany was treated harshly in the Treaty of Versailles (1919). Wilson refused to compromise with Senate Republicans over the issue of Congressional power to declare war, and the Senate rejected the Treaty and the League.[189] Instead, the United States chose to pursue unilateralism.[190] The aftershock of Russia's October Revolution resulted in real fears of Communism in the United States, leading to a Red Scare and the deportation of non-citizens considered subversive.\n Despite the Progressive-era modernization of hospitals and medical schools,[191] the country lost around 550,000 lives to the Spanish flu pandemic in 1918 and 1919.[192][193] During the \"Roaring\" 1920s, the economy expanded. African-Americans benefited from the Great Migration and had more cultural power; an example being the Harlem Renaissance which spread jazz music. Meanwhile, the Ku Klux Klan had a resurgence, and the Immigration Act of 1924 was passed to strictly limit the number of new entries.[194] Prohibition began in 1920, when the manufacture, sale, import and export of alcohol were prohibited by the Eighteenth Amendment. Americans resulted to drinking denatured alcohol or bootlegged alcohol from elsewhere in the Americas. Bootlegged alcohol in the cities ended up under the control of gangs, who fought each other for territory in which they controlled the drink's sale. Italian bootleggers in New York City gradually formed the Mafia crime syndicate. In 1933, President Franklin D. Roosevelt repealed prohibition by signing the Cullen-Harrison Act.[195] The Great Depression (1929–1939) and the New Deal (1933–1936) were decisive moments in American political, economic, and social history that reshaped the nation.[196] During the 1920s, the nation enjoyed widespread prosperity, albeit with a weakness in agriculture. A financial bubble was fueled by an inflated stock market, which later led to the Wall Street Crash on October 29, 1929.[197] This, along with many other economic factors, triggered a worldwide depression. During this time, the United States experienced deflation as prices fell, unemployment soared from 3% in 1929 to 25% in 1933, farm prices fell by half, and manufacturing output plunged by one-third.\n In 1932, Democratic presidential nominee Franklin D. Roosevelt promised \"a New Deal for the American people\", coining the enduring label for his domestic policies. The result was a series of permanent reform programs including the Social Security program, unemployment relief and insurance, public housing, bankruptcy insurance, farm subsidies, and regulation of financial securities.[198] It also provided unemployment relief through the Works Progress Administration (WPA) and for young men, the Civilian Conservation Corps. Large scale spending projects designed to provide private sector construction jobs and rebuild the infrastructure were under the purview of the Public Works Administration.[198] State governments added new programs as well, and introduced the sales tax to pay for them. Ideologically, the New Deal established modern liberalism in the United States and kept the Democrats in power in Washington almost continuously for three decades, thanks to the New Deal coalition of ethnic white and Black people, blue-collar workers, and labor unions.[198] The New Deal coalition won re-election for Roosevelt in 1936, 1940, and 1944.[198] The Second New Deal in 1935 and 1936 brought the economy further left, building up labor unions through the Wagner Act. Roosevelt weakened his second term by a failed effort to pack the Supreme Court, which had been a center of conservative resistance to his programs.[198] The economy essentially recovered by 1936, but had a sharp, short recession in 1937 and 1938. Long-term unemployment, however, remained a problem until it was solved by wartime spending. Most of the relief programs were dropped in the 1940s, when the conservatives regained power in Congress through the Conservative coalition.[198] In an effort to denounce past U.S. interventionism and create a friendly relationship with Latin America, Roosevelt announced in 1933 he would stray from asserting military force in the region.[199][200] For Hispanics in the United States, the Depression was a difficult period, as the Mexican Repatriation resulted in the dislocation of an estimated 400,000 Mexicans and Mexican Americans.[201] During the Depression, the United States remained focused on domestic concerns, while democracy declined across the world and many countries fell under the control of dictators. Imperial Japan asserted dominance in East Asia and in the Pacific. Nazi Germany and Fascist Italy militarized and threatened conquests of their neighbors, while Britain and France attempted appeasement to avert another war in Europe. U.S. legislation in the Neutrality Acts sought to avoid foreign conflicts; however, policy clashed with increasing anti-Nazi feelings following the German invasion of Poland in September 1939 that started World War II.[202] At first, Roosevelt positioned the U.S. as the \"Arsenal of Democracy\", pledging full-scale financial and munitions support for the Allies and Lend-Lease agreements – but no military personnel.[202] Japan tried to neutralize America's power in the Pacific by attacking Pearl Harbor in 1941, but instead it catalyzed American support to enter the war.[203] War fervor inspired anti-Japanese sentiment, leading to internment of Japanese Americans.[204] Roosevelt's Executive Order 9066 resulted in over 120,000 Americans of Japanese descent being removed from their homes and placed in internment camps. Two-thirds of those interned were American citizens, and half of them were children.[205][206][207] The Allies – the United States, Britain, the Soviet Union, China and other countries – fought against Germany in the European theater and Japan in the Pacific War.[208] The United States was one of the \"Allied Big Four\", alongside the United Kingdom, Soviet Union, and China.[209][210] The U.S. gave the Allied war effort money, food, petroleum, technology, and military personnel. The U.S. focused on maximizing its national economic output, causing a dramatic increase in GDP, the end of unemployment, and a rise in civilian consumption, even as 40% of the GDP went to the war effort.[196] A wartime production boom led to the end of the Great Depression. Tens of millions of workers moved into the active labor force and to higher-productivity jobs. Labor shortages encouraged industries to look for new sources of workers, finding new roles for women and Black people. Economic mobilization was managed by the War Production Board.[196] Most durable goods became unavailable, and meat, clothing, and gasoline were tightly rationed. In industrial areas, housing was in short supply, as people lived in cramped quarters. Prices and wages were controlled, and Americans saved a high portion of their incomes, which led to renewed growth after the war.[211][212] The U.S. stopped Japanese expansion in the Pacific in 1942; after the loss of the Philippines to Japanese conquests, as well as a draw in the Battle of the Coral Sea in May, the American Navy then inflicted a decisive blow at Midway in June 1942. The Allied forces built up a garrison on Guadalcanal, a Pacific island formerly held by the Japanese, after the successes of the Battle of the Eastern Solomons and the Battle of Guadalcanal. The Japanese then stopped advancing south, and the U.S. began taking New Guinea. Japan also lost their invasion of the Alaskan Aleutian Islands, allowing the U.S. to begin attacking the Japanese-controlled Kuril Islands.[208] American ground forces assisted in the North African campaign that eventually concluded with the collapse of Fascist Italy in 1943, as Italy switched to the Allied side. A more significant European front was opened on D-Day, June 6, 1944, in which Allied forces invaded Nazi-occupied France from Britain.[208] The Allies began pushing the Germans out of France in the Normandy campaign, breaking through the local German defenses after Operation Cobra in August. This also led to conflict within the German high command, and the unsuccessful July Plot. After French and American forces landed at the French Riviera in Operation Dragoon, Hitler allowed his army to retreat from Normandy.[213] Roosevelt died in 1945, and was succeeded by Harry Truman.[214] The western front stopped short of Berlin, leaving the Soviets to take it in the Battle of Berlin. The Nazi regime formally capitulated in May 1945, ending the war in Europe.[208] In the Pacific, the U.S. implemented an island hopping strategy toward Tokyo. The Philippines was eventually reconquered, after Japan and the United States fought in history's largest naval battle, the Battle of Leyte Gulf.[215] However, the war wiped out all the development the United States invested in the Philippines, as cities and towns were completely destroyed.[216] After the war, the U.S. granted the Philippines independence.[217] Military research and development increased during the war, leading to the Manhattan Project, a secret effort to harness nuclear fission to produce atomic bombs.[218] The first nuclear device ever detonated was conducted on July 16, 1945.[219] Meanwhile, the U.S. established airfields for bombing runs against mainland Japan from the Mariana Islands, achieving hard-fought victories at Iwo Jima and Okinawa in 1945.[220] The U.S. prepared to invade Japan's home islands when they dropped atomic bombs on the Japanese cities of Hiroshima and Nagasaki, compelling Japan to surrender and ending World War II.[221] The U.S. occupied Japan (and part of Germany), and restructured Japan along American lines.[222] 400,000 American military personnel and civilians were killed.[223] Nuclear weapons have not been used since the war ended, and a \"long peace\" began between the global powers in era of competition that came to be known as the Cold War.[224] In the decades after World War II, the United States became a global influence in economic, political, military, cultural, and technological affairs. Following World War II, the United States emerged as one of the two dominant superpowers, the Soviet Union being the other. The U.S. Senate, on a bipartisan vote, approved U.S. participation in the United Nations (UN), which marked a turn away from traditional American isolationism and toward increased international involvement.[225] The United States and other major Allied powers — the United Kingdom, Soviet Union, and China — became the foundation of the UN Security Council.[226] The Central Intelligence Agency (CIA) was created in 1947.[227] America wished to rescue Europe from the devastation of World War II, and to contain the expansion of communism, represented by the Soviet Union. U.S. foreign policy during the Cold War was built around the support of Western Europe and Japan along with the policy of containment (containing the spread of communism to countries already under that system).[228] The Truman Doctrine in 1947 was the U.S.' attempt to secure trading partners in Europe, by providing military and economic aid to Greece and Turkey to counteract the threat of communist expansion in the Balkans.[229][224] In 1948, the United States replaced piecemeal financial aid programs with a comprehensive Marshall Plan, which pumped money into Western Europe, and removed trade barriers, while modernizing the managerial practices of businesses and governments.[230] Post-war American aid to Europe totaled $25 billion, out of the U.S. GDP of $258 billion in 1948. Soviet head of state Joseph Stalin prevented his satellite states from participating, and from that point on, Eastern Europe, with inefficient centralized economies, fell further and further behind Western Europe in terms of economic development and prosperity.[230] In Asia, despite being devastated by World War 2 and being a former colony, the Philippines, received negligible assistance from the United States compared to the larger aid given to other Asian allies like: Israel, South Korea, South Vietnam,[231] and Taiwan,[232] because the latter had hostile Pro-Soviet Union neighbors which the United States were opposed to.[233] In 1949, the United States, rejecting the long-standing policy of no military alliances in peacetime, formed the North Atlantic Treaty Organization (NATO) alliance, which continues into the 21st century. In response, the Soviets formed the Warsaw Pact of communist states, leading to the \"Iron Curtain\".[230] In 1949, the Soviets performed their first nuclear weapon test.[224] This escalated the risk of nuclear warfare; the threat of mutually assured destruction, however, prevented both powers from nuclear war, and resulted the proxy wars in which the two sides did not directly confront each other.[224] The U.S. fought against communists in the Korean War and Vietnam War, and toppled left-wing governments in the third world to try to stop its spread, such as Iran in 1953 and Guatemala in 1954.[228]McCarthyism was a widespread government program led by Senator Joseph McCarthy to expose communists in government and business. Government employees were made to prove their loyalty to America, and Hollywood was targeted by the House Un-American Activities Committee.[234]J. Robert Oppenheimer, director of the Los Alamos Laboratory during the Manhattan Project, had his high-level security clearance revoked in 1954 over alleged communist sympathies, losing his ability to advise the top heads of government.[235][236] Gay people were targeted under the McCarthyist Lavender Scare.[237] Dwight D. Eisenhower was elected president in 1952 in a landslide.[238] He ended the Korean War, and avoided any other major conflict. He cut military spending by relying on advanced technology, such as nuclear weapons carried by long-range bombers and intercontinental missiles.[239] After Stalin died in 1953, Eisenhower worked to obtain friendlier relationships with the Soviet Union. At home, he ended McCarthyism, expanded the Social Security program, and presided over a decade of bipartisan cooperation.[239] Domestically, after 1948, America entered an economic boom. Americans found themselves flush with cash from wartime work, due to there being little to buy for several years. As a result, 60% of the American population had attained a \"middle-class\" standard of living by the mid-1950s (defined as incomes of $3,000 to $10,000 in constant dollars), compared with only 31% in the 1928 and 1929. Between 1947 and 1960, the average real income for American workers increased by as much as it had in the previous half-century.[240] The economy allowed for an affordable lifestyle with large families; this created the baby boom, in which millions of children were born at increased rates from 1945 to 1964. The baby boomer demographic eventually made up 40 percent of the country.[241] Many Americans moved into suburban neighborhoods.[242] Eisenhower promoted civil rights for African-Americans cautiously.[239] In the 1954 Supreme Court decision Brown v. Board of Education, public school segregation was ruled unconstitutional.[243] When nine Black students were threatened over their admission into all-white Little Rock Central High School, Eisenhower sent in a thousand National Guard troops to ensure peace.[239] Starting in the late 1950s, institutionalized racism across the United States, but especially in the South, was increasingly challenged by the growing civil rights movement. The activism of Rosa Parks and Martin Luther King Jr. led to the boycott of segregated public buses in Montgomery, Alabama in 1955, organized by King and the Montgomery Improvement Association. They faced multiple acts of violence, but continued the boycott for a year, until the Supreme Court ordered the city to desegregate the buses. In 1957, King created the Southern Christian Leadership Conference to facilitate future protests.[243] The Soviets unexpectedly surpassed American technology in 1957 with Sputnik, the first Earth satellite. The R-7 missile which launched Sputnik into space could have hypothetically dropped a nuclear bomb into U.S. air space from above; new American fears regarding Soviet power began the Space Race, a competition between the two countries to prove their technological superiority through space exploration. In 1958, Eisenhower created the National Aeronautics and Space Administration (NASA) for this purpose, and in 1958, the U.S. launched the Explorer I satellite. In 1961, Eisenhower's newly elected successor, John F. Kennedy, announced the U.S. would land a man on the moon by the end of the decade.[244] Angst about the weaknesses of American education led to large-scale federal support for science education and research.[245] In 1960, John F. Kennedy was elected President and his administration saw the acceleration of the country's role in the Space Race, escalation of the American role in the Vietnam War, the Bay of Pigs Invasion, and the Cuban Missile Crisis. President Kennedy was assassinated on November 22, 1963, leaving the nation in profound shock.[246]Lyndon B. Johnson then became president.[247] Johnson was rewarded with an electoral landslide in 1964 against conservative Barry Goldwater.[247] He then secured congressional passage of his Great Society programs,[248] dealing with civil rights, the end of legal segregation, Medicare, extension of welfare, federal aid to education at all levels, subsidies for the arts and humanities, environmental activism, and a series of programs designed to wipe out poverty.[249][250] For years, civil rights activists were victims of violence, but they would achieve great steps toward equality with Supreme Court decisions like Loving v. Virginia, and laws like the Civil Rights Act of 1964, the Voting Rights Act of 1965, and the Fair Housing Act of 1968. These ended the Jim Crow laws that legalized racial segregation between white and Black people.[251] Native Americans protested federal courts, highlighting the federal government's failure to honor treaties involving them. One of the most outspoken Native American groups was the American Indian Movement (AIM). In the 1960s, Cesar Chavez began organizing poorly paid Mexican-American farm workers in California. He led a five-year-long strike by grape pickers. Then Chávez formed the country's first successful union of farm workers, the United Farm Workers of America (UFW).[252] Amid the Cold War, the United States entered the Vietnam War, whose growing unpopularity fed already existing social movements, including those among women, minorities, and young people. Feminism and the environmental movement became political forces, and progress continued toward civil rights for all Americans. A counterculture revolution swept through the nation and much of the western world in the late sixties and early seventies, further dividing Americans in a \"culture war\" but also bringing forth more liberated social views.[253] Frustrations with the seemingly slow progress of the integration movement led to the emergence of more radical politics, such as Black Power movement of the late 1960s and early 1970s.[254] The summer of 1967 saw opposing philosophies in two widespread movements, the more peaceful summer of love and the radical long, hot summer, which included nationwide riots.[255] Martin Luther King Jr. was assassinated in 1968.[256] Following his death, there were further riots, and others led the movement, most notably his wife, Coretta Scott King.[256][257] The modern gay rights movement started after the Stonewall riots in 1969.[258] A new consciousness of the inequality of American women began sweeping the nation, starting with the 1963 publication of Betty Friedan's best-seller, The Feminine Mystique, which critiqued the American cultural idea that women could only find fulfillment through their roles as wives, mothers, and keepers of the home, arguing that women should join the workforce. In 1966, Friedan and others established the National Organization for Women (NOW) to advocate for women's rights.[178][259] Protests began, and the new women's liberation movement grew in size and power, gaining much media attention. There were striking gains for women in medicine, law, and business, while only a few were elected to office.[260] The proposed Equal Rights Amendment to the Constitution, passed by Congress in 1972 was defeated by a conservative coalition mobilized by Phyllis Schlafly.[260][261] However, many federal laws stablished women's equal status under the law, such as those equalizing pay, employment, education, employment opportunities, and credit between genders, ending pregnancy discrimination, and requiring organizations like NASA to admit women. State laws criminalized spousal abuse and marital rape, and the Supreme Court ruled that the equal protection clause of the Fourteenth Amendment applied to women. Social custom and consciousness began to change, accepting women's equality. The controversial issue of abortion, deemed by the Supreme Court as a fundamental right in Roe v. Wade (1973), is still a point of debate today.\n In March 1968, Johnson announced he would not run for a second full term in office.[262] This was partially because Robert F. Kennedy, who was against the Vietnam War, entered the Democratic primary race. The war was increasingly controversial after the recent Tet Offensive. Kennedy was assassinated in June. The winner of the primaries was Hubert Humphrey; his policies regarding the Vietnam War led to riots at the party's convention that year.[263][264] Humphrey was defeated by Republican Richard Nixon,[263] who largely continued the New Deal and Great Society programs he inherited.[247][265] The Republican Party expanded its base throughout the South after 1968, largely due to its strength among socially conservative white Evangelical Protestants and traditionalist Roman Catholics, adding to its traditional strength in the business community and suburbs. The Democratic party also started moving to the right-center.[266] Nixon created the Environmental Protection Agency,[267]opened relations with China, and attempted to gradually turn the Vietnam War effort over to the South Vietnamese forces. He negotiated the peace treaty in 1973 which secured the release of POWs and led to the withdrawal of U.S. troops. The war had cost the lives of 58,000 American troops. Nixon manipulated the fierce distrust between the Soviet Union and China to the advantage of the U.S., achieving détente with both parties.[265] He was also president during the U.S.' landing on the Moon in 1969.\n The Watergate scandal, involving Nixon's cover-up of his operatives' break-in into the Democratic National Committee headquarters at the Watergate office complex destroyed his political base, sent many aides to prison, and forced his resignation on August 9, 1974.[265] He was succeeded by Vice President Gerald Ford, who pardoned Nixon for Watergate.[265][268] The Fall of Saigon on April 30, 1975, ended the Vietnam War, and resulted in North and South Vietnam being reunited. Communist victories in neighboring Cambodia and Laos occurred in the same year, with the fall of Cambodia's capital, Phnom Penh on April 17 and the taking of Laos's capital, Vientiane on December 2.[265] In Central America, the U.S. government supported right-wing governments against left-wing groups, such as in El Salvador and Guatemala. In South America, they supported Argentina and Chile, who carried out Operation Condor, a campaign of assassinations of exiled political opponents by Southern Cone governments, which was created at the behest of Chilean dictator Augusto Pinochet in 1975.[269][270][271] \nThe OPEC oil embargo marked a long-term economic transition since, for the first time, energy prices skyrocketed, and American factories faced serious competition from foreign automobiles, clothing, electronics, and consumer goods. By the late 1970s, the economy suffered an energy crisis, slow economic growth, high unemployment, and very high inflation, coupled with high-interest rates. The term stagflation was coined to define these trends. Since economists agreed on deregulation, many of the New Deal era regulations were ended, such as in transportation, banking, and telecommunications.[272] Meanwhile, the first mass-market personal computers were being developed in California's Silicon Valley.[273] Jimmy Carter, running as someone who was not a part of the Washington political establishment, was elected president in 1976.[274] Carter brokered the Camp David Accords between Israel and Egypt. In 1979, Iranian students stormed the U.S. embassy in Tehran and took 66 Americans hostage, resulting in the Iran hostage crisis. With the hostage crisis and continuing stagflation, Carter lost the 1980 election to the Republican Ronald Reagan.[275] On January 20, 1981, minutes after Carter's term ended, the remaining U.S. captives were released.\n The Republican Party's central leader by 1980 was president Ronald Reagan, whose conservative policies produced a major political realignment with his 1980 and 1984 landslide elections.[266][276] Reagan's neoliberal economic policies (dubbed \"Reaganomics\"), including the implementation of the Economic Recovery Tax Act of 1981, lowered the top marginal tax rate from 70% to 28% over the course of seven years.[276][277][278] Reagan continued to downsize government taxation and regulation;[279] New Deal and Great Society programs were ended.[247] The U.S. experienced a recession in 1982, but after inflation decreased, unemployment then decreased, and the economic growth rate increased from 4.5% in 1982 to 7.2% in 1984.[280][281] However, homelessness and economic inequality also rose.[282][283] The Reagan administration's expansion of the War on Drugs led to an increase in incarceration, particularly among African Americans, with the number of people imprisoned for drug offences rising from 50,000 to 400,000 between 1980 and 1997.[284][285] Manufacturing industries moving out of inner cities increased poverty in those areas; poverty increased drug dealing and contributed to the crack epidemic, which in turn led to increased crime and incarceration.[284][286] The government also reacted slowly to the AIDS crisis, and banned reliable information on the disease, which led to higher infection rates.[287][288] Reagan ordered a buildup of the U.S. military, incurring additional budget deficits.[289] The 1983 invasion of Grenada and 1986 bombing of Libya were popular in the U.S., though Reagan's backing of the Contra rebels was mired in the controversy over the Iran–Contra affair.[290] Reagan also introduced a complicated missile defense system known as the Strategic Defense Initiative (SDI). The Soviets reacted harshly because they thought it violated the 1972 Anti-Ballistic Missile Treaty, and would upset the balance of power by giving the U.S. a major military advantage, so they stopped negotiating disarmament deals until the late 1980s.[289] Historians debate over if the SDI forced Soviet leader Mikhail Gorbachev to initiate radical reforms, or whether the deterioration of the Soviet economy alone forced the reforms.[291] Reagan met four times with Gorbachev, and their summit conferences led to the signing of the Intermediate-Range Nuclear Forces Treaty. Gorbachev tried to save communism in the Soviet Union, first by ending the expensive nuclear arms race with America.[292] However, the Soviet Union collapsed in 1991, ending the Cold War.[293] For the remainder of the 20th century, the United States emerged as the world's sole remaining superpower and continued to intervene in international affairs during the 1990s.[294] The Gulf War against Iraq started during George H.W. Bush's administration.[294] The war started when Iraq invaded neighboring Kuwait in 1990. After a \"massive\", international U.S.-led offensive, Kuwait was taken back. Under Bush, the U.S. also became involved in wars in Panama, Somalia, Bosnia, and Croatia.[295][296][297] In 1992, there were riots in Los Angeles over police brutality.[298] Following his election in 1992, President Bill Clinton oversaw one of the longest periods of economic expansion and unprecedented gains in securities values. President Clinton worked with the Republican Congress to pass the first balanced federal budget in 30 years.[294] Much of the economic boom was a side effect of the Digital Revolution, and new business opportunities created by the Internet (which started as the government project ARPANET).[299] During Clinton's administration, the U.S. was involved in wars in Haiti and Kosovo.[300][301] White Democrats in the South lost dominance of the Democratic Party in the 1990s.[266] Conservative Republicans heavily won the 1994 midterm elections in a \"Republican Revolution\" which was built around the Contract with America policy agenda.[302][303]Newt Gingrich was chosen as House Speaker,[302] and he would heavily influence the Republican Party to engage in \"confrontational\" political speech.[304][305] In response, in June 1995, Clinton shifted his policies more towards the center from the left. This did not majorly increase his approval, but rather, his leadership after the Oklahoma City bombing in April did.[306] He won in the 1996 presidential elections.[307] In 1998, Clinton was impeached by the House of Representatives on charges of lying under oath about a sexual relationship with White House intern Monica Lewinsky. He was acquitted by the Senate. The failure of impeachment and the Democratic gains in the 1998 election forced Gingrich to resign from Congress.[294] In 2000, the dot-com bubble, a widespread overvaluation of Internet company stocks, burst and hurt the U.S. economy.[308][309] The close presidential election in 2000 between Governor George W. Bush and Al Gore helped lay the seeds for political polarization to come. The vote in the decisive states of New Mexico and Florida was extremely close and produced a dramatic dispute over the counting of votes.[310] Bush ultimately won. Including 2000, the Democrats outpolled the Republicans in the national vote in every election from 1992 to 2020, except for 2004.[311] On September 11, 2001 (9/11), the United States was struck by a terrorist attack, when 19 al-Qaeda hijackers commandeered four commercial planes to be used in suicide attacks. Two were crashed intentionally into both Twin Towers of the World Trade Center in New York City, and a third into the Pentagon in Arlington, Virginia. The fourth plane was re-taken by the passengers and crew of the aircraft, and it was crashed into an empty field in Pennsylvania, killing everyone on board and saving whatever target the terrorists were aiming for. Every building of the World Trade Center partially or completely collapsed, massively damaging the surrounding area and blanketing Lower Manhattan in toxic dust clouds. A total of 2,977 victims died in the attacks. In response, on September 20, Bush announced a \"war on terror\".[312][313] In October 2001, the U.S. and NATO invaded Afghanistan and ousted the Taliban regime, which had harbored al-Qaeda and its leader Osama bin Laden.[314] Bin Laden then escaped to Pakistan, starting a manhunt for him.[315] The U.S. established new domestic efforts to prevent future attacks. The Patriot Act increased the power of government to monitor communications and removed legal restrictions on intelligence sharing between federal law enforcement agencies.[316] The government's indefinite detention of terrorism suspects captured abroad at the Guantanamo Bay detention camp, a prison at the U.S. naval base in Guantanamo Bay, Cuba, led to allegations of human rights abuses and violations of international law.[317][318][319] The Department of Homeland Security was created to lead federal counter-terrorism activities.[316] In March 2003, the U.S. launched an invasion of Iraq, claiming Iraqi dictator Saddam Hussein had weapons of mass destruction (WMDs) and the Iraqi people needed to liberated from him. Intelligence backing WMDs were later found to be inaccurate. The war led to the collapse of the Iraqi government and the eventual capture of Hussein.[320][321] Despite some initial successes early in the invasion, the continued Iraq War fueled international protests and gradually saw domestic support decline as many people questioned if the invasion was worth the cost.[322][323] In 2005, Hurricane Katrina killed 1,800 people around New Orleans after the city's levees broke.[324] In 2007, after years of violence by the Iraqi insurgency, Bush deployed more troops in a strategy dubbed \"the surge\". While the death toll decreased, the political stability of Iraq remained in doubt.[325] In December 2007, the U.S. unemployment rate rose from 5% to 10%.[326] In 2008, the U.S. entered the Great Recession.[327][328] Multiple overlapping crises were involved, especially the housing market crisis, a subprime mortgage crisis, soaring oil prices, an automotive industry crisis, rising unemployment, and the worst financial crisis since the Great Depression. The financial crisis threatened the stability of the entire economy in September 2008, when Lehman Brothers failed, and other giant banks were in grave danger.[329] Starting in October, the federal government lent $245 billion to financial institutions through the bipartisan Troubled Asset Relief Program.[330][331] The unpopularity of Bush and the Iraq War, along with the financial crisis, led to the 2008 election of Barack Obama, the first multiracial[332] president, with African-American or Kenyan ancestry.[333] He won by a wide electoral margin.[334] He signed the Don't Ask, Don't Tell Repeal Act, which allowed people to serve in the military while openly gay.[335] To help the economy, he signed the American Recovery and Reinvestment Act of 2009,[336]Consumer Assistance to Recycle and Save Act,[337] the Patient Protection and Affordable Care Act (informally \"Obamacare\"),[338] and the Dodd–Frank Wall Street Reform and Consumer Protection Act.[339][340] The employment rate began falling as the economy and labor markets experienced a recovery.[326] These changes to the economic system created new political movements, such as the liberal Occupy movement and the conservative Tea Party movement.[341] The recession officially ended in June 2009, and the economy slowly began recovering.[342] Following the 2010 midterm elections, which resulted in a Republican-controlled House of Representatives and a Democratic-controlled Senate,[343] Congress was in gridlock, as heated debates were held over whether or not to raise the debt ceiling, extend tax cuts for citizens making over $250,000 annually, and how to address other key issues.[344] These ongoing debates led to the Budget Control Act of 2011.[345] The economic expansion that followed the Great Recession was the longest in U.S. history;[346][347] the unemployment rate reached a 50-year low in 2019.[348] Despite the strong economy, increases in the cost of living surpassed increases in wages.[349][350] The economic expansion came to an end in early 2020, largely caused by the COVID-19 pandemic.[346][347] In 2009, Obama issued an executive order banning the use of torture,[351][352] a prohibition codified into law in 2015.[353] He ordered the closure of secret CIA-run prisons overseas,[354][355] and sought to close the Guantanamo Bay detention camp, but his efforts were stymied by Congress, which in 2011 enacted a measure blocking him from transferring any Guantanamo detainees to U.S. facilities. The number of inmates nonetheless was decreased.[356][357] Obama reluctantly continued the war effort in Iraq until August 2010, when he declared that combat operations had ended. However, 50,000 American soldiers and military personnel were kept in Iraq for safety reasons until they left the country in December 2011.[358] Meanwhile, he increased involvement in Afghanistan, adding an additional 30,000 troops, while proposing to begin withdrawing troops in 2014.[352] The U.S., with NATO, intervened in the Libyan Civil War for seven months in 2011.[359] In May 2011, Osama bin Laden was killed in Pakistan in a raid ordered by Obama and conducted by Navy SEALs. While Al Qaeda was near collapse in Afghanistan, affiliated organizations continued to operate in Yemen and other remote areas, as the CIA used drones to hunt down its leadership.[360][361] In October, Obama sent troops to Central Africa to fight the Lord's Resistance Army.[362] Following Obama's 2012 re-election, Congressional gridlock continued. Congressional Republicans' demands, like calling for the repeal of the Affordable Care Act, resulted in the first government shutdown since the Clinton administration, and almost led to the first default on U.S. debt since the 19th century. As a result of growing public frustration with both parties in Congress, Congressional approval ratings fell to record lows.[363] In 2012, the Sandy Hook Elementary School shooting in Newtown, Connecticut led to unsuccessful attempts from Obama to promote gun reform.[364] The Boston Marathon bombing of 2013 killed three people and injured more than 260.[365] Also that year, NSA employee Edward Snowden leaked information regarding the NSA's widespread program of surveilling American citizens through the Internet.[366] \nIn 2013, the U.S. also started a counter-terrorist invention in Niger,[367] and began a covert operation to train rebels in Syria who were fighting against the terrorist group ISIS. The latter program was publicized and expanded in 2014.[368] That year, ISIS grew in scope in the Middle East, and inspired many terrorist attacks in the United States, including the 2015 San Bernardino attack.[369][370][371] The U.S. and its allies began a significant military offensive against ISIS in Iraq which lasted from 2014 to 2021.[372][373] In December 2014, Obama officially ended the combat mission in Afghanistan and promised a withdrawal of almost all remaining U.S. troops at the end of 2016.[374] However, troops stayed until 2021.[375] The shooting of Black teen Michael Brown by police officer Darren Wilson, and a grand jury declining to charge Wilson with murder, led to the Ferguson unrest in Missouri in 2014 and 2015.[376] In 2015, U.S. also joined the international Paris Agreement on climate change.[377] Meanwhile, debate over the issue of rights for the LGBT community, including same-sex marriage, began to shift in favor of same-sex couples.[378] In 2012, President Obama became the first president to openly support same-sex marriage.[379] The Supreme Court provided federal recognition of same-sex marriages in 2013,[380] and then legalized gay marriage nationwide with Obergefell v. Hodges in 2015.[381] \nIn November 2016, following a contentious election against Hillary Clinton, Republican Donald Trump was elected president.[382] The election's legitimacy was disputed when the FBI and Congress investigated if Russia interfered in the election to help Trump win. There were also accusations of collusion between Trump's campaign and Russian officials. The Mueller report concluded that Russia attempted to help Trump's campaign, but there was no evidence of \"explicit\" collusion found.[383][384][385] Trump, however, \"welcomed help from Russia\"; in July 2016, after WikiLeaks published emails from the Democratic National Committee (DNC) – initially suspected to be obtained by Russian hackers – Trump publicly asked Russia to find emails that were deleted from Clinton's private email server that she used as Obama's Secretary of State. In 2018, the DNC emails were confirmed to be obtained by a Russian hacker or hacker group named Guccifer 2.0.[384][386][387][388] In the 2010s and early 2020s, Americans became more politically polarized.[389][390][391] The #MeToo movement exposed alleged sexual harassment and abuse in the workplace.[392] Many celebrities were accused of misconduct or rape.[393][394] The Black Lives Matter movement gained support after multiple police killings of African-Americans.[395] White supremacy also grew.[396][397][398] The 2017 Women's March against Trump's presidency was one of the largest protests in American history.[399] Multiple mass shootings, including the 2016 Pulse Nightclub shooting, 2017 Las Vegas shooting, and 2018 Parkland shooting, led to increased calls for gun reform, such as in the March for Our Lives student protest movement.[400][401] During Trump's presidency, he espoused an \"America First\" ideology, placing restrictions on asylum seekers, expanding the wall on the U.S.-Mexico border, and banning immigration from seven Muslim-majority countries. Many of his executive orders and other actions were challenged in court.[402][403][404] He confirmed three new Supreme Court justices (cementing a conservative majority),[405] started a trade war with China,[406] signed the Tax Cuts and Jobs Act, and removed the U.S. from the Paris Agreement.[377] In 2018, the administration separated families which were illegally immigrating to the country. After public outcry, Trump rescinded the policy.[407][408] In 2019, a U.S. attack caused the suicide of the leader of ISIS, Abu Bakr al-Baghdadi.[409] A whistleblower complaint also alleged that Trump had withheld foreign aid from Ukraine under the demand that they investigate the business dealings of Hunter Biden; Hunter's father, Democrat Joe Biden, would be Trump's opponent in the 2020 presidential election.[410][411] Trump was impeached for abuse of power and obstruction of congress, but he was acquitted in 2020.[412] The COVID-19 disease started spreading in China in 2019.[413] In March 2020, the WHO declared the spread to be a pandemic.[414] American state and local governments imposed stay-at-home orders to slow the virus' spread, reducing patient overload in hospitals. By April, the U.S. had the most cases of any country, at 100,000.[415][416][417] At Trump's direction, the Centers for Medicare & Medicaid Services and Centers for Disease Control released preventative guidelines for Americans.[418] On April 11, the U.S. death toll became the highest in the world at 20,000,[419] and by May 2022, one million had died.[420] U.S. life expectancy fell by around a year and a half in 2020 and 2021, and unemployment rates were the highest since the Great Depression.[421][422] The biggest mass vaccination campaign in U.S. history started in December 2020, when the Pfizer-BioNTech COVID-19 vaccine was first distributed to U.S. citizens.[423] By October 2022, 613 million vaccine shots had been administered to Americans.[424] \nThe May 2020 murder of George Floyd caused mass protests and riots in many cities over police brutality, with many states calling in the National Guard.[425] Many organizations attempted to rid themselves of institutionalized racism.[426] 2020 was also marked by a rise in domestic terrorist threats and widespread conspiracy theories around mail-in voting and COVID-19.[427][428][429] The QAnon conspiracy theory gained publicity due to greater Internet usage during the pandemic.[430][431] Multiple major cities were hit by rioting and fighting between far-left anti-fascist groups and far-right groups like the Proud Boys.[432][433] Joe Biden defeated Trump in the 2020 election, the first defeat of an incumbent president since 1992.[411] The election, with an exceptional amount of mail-in voting and early voting due to the pandemic, had historically high voter turnout.[434] Trump then repeatedly made false claims of massive voter fraud and election rigging,[435][436][437] leading to the January 6 United States Capitol attack by supporters of Trump and right-wing militias.[438][439] The attack was widely described as a coup d'état.[440][441][442] It led to Trump's impeachment for incitement of insurrection, making him the only U.S. president to be impeached twice.[443][444][445] The Senate later acquitted Trump, despite some fellow Republicans voting against him.[446][447]Kamala Harris was inaugurated as the first Black, Asian, and female vice president.[448] In 2021, Biden finished the withdrawal of American troops from Afghanistan which started under Trump. After an evacuation of over 120,000 American citizens, Afghanistan fell to the Taliban in August.[375][449][450] Biden signed into law the American Rescue Plan Act of 2021; a $1.9 trillion stimulus bill in response to continued economic pressure from COVID-19.[451] He also proposed a significant expansion of the social safety net through the Build Back Better Act, but those efforts, along with voting rights legislation, failed in Congress.[452] He then signed bills regarding infrastructure,[453]gun reform,[454]inflation reduction,[455] and healthcare for veterans,[456] among other issues.[457] The Delta variant of SARS-CoV-2, the virus that causes COVID-19, started spreading in 2021. New preventative restrictions were put in place in reaction to this.[458][459][460] In the early 2020s, Republican-led states began sweeping rollbacks of LGBT rights.[461] In 2022, the Supreme Court ruled in Dobbs v. Jackson that having an abortion is not a protected Constitutional right, overturning Roe v. Wade and Planned Parenthood v. Casey and sparking nationwide protests.[462][463] Biden also appointed Ketanji Brown Jackson to become the first Black woman to serve on the court.[464] In 2023, Trump began appearing in court as a defendant in multiple notable criminal trials, including alleged federal crimes,[465] while he was campaigning for the 2024 presidential election.[466] Meanwhile, the U.S. began supporting Israel in the Israel-Hamas war[467] and protecting shipping in the Red Sea from attacks by the Yemeni Houthis.[468] In June 2024, Trump became the first president convicted of a crime, when he was found guilty of 34 felony counts for falsifying business documents related to his paying off of Stormy Daniels in 2016.[469] In July, the Supreme Court ruled in Trump v. United States that presidents are somewhat immune from criminal prosecution after their presidency over \"official acts\" taken during their presidency, helping Trump before his planned election subversion trial;[470][471][472] the trial was later dismissed by a Trump-appointed judge.[473] Later in July, Biden dropped out of the 2024 race, endorsing Kamala Harris.[474] During the election season, there were two assassination attempts on Trump.[475] Trump won the 2024 presidential election. Trump and JD Vance are scheduled to be inaugurated on January 20, 2025. Trump is the first president to be elected to a non-consecutive second term in 132 years, since Grover Cleveland won the 1892 election and became the oldest person ever elected, winning both the popular and electoral vote. \n"
I want to know which years are mentioned in the text.
Write a regex that can extract all the years from the text. Don’t worry about any years before 1000, its a young country.