---
schema_version: "1"
id: 92edc8a7d83726e64970531a517e4cec06b9e1f10f8b8ac38134c444d61cae06
title: Using Regions
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/apex_classes_pattern_and_matcher_regions.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_pattern_and_matcher_regions.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 775ae2d55604808fe0f7e75982761d8568187b1340f6be29e944e33a17b7a82b
description: A Matcher object finds matches in a subset of its input string called a region. The default region for a Matcher object is always the entirety of the input string. However, you can change the start and end points of a region by using the region method, and you can query the region's end points by using the regionStart and regionEnd methods.
---
# Using Regions

A Matcher object finds matches in a subset of its input string called a region. The default region for a Matcher object is always the entirety of the input string. However, you can change the start and end points of a region by using the region method, and you can query the region's end points by using the regionStart and regionEnd methods.

The region method requires both a start and an end value. The following examples show how to set one value without setting the other.

## Set the start of the region explicitly; leave end unchanged.

MyMatcher.region(start, MyMatcher.regionEnd());

## Leave start unchanged; set the end of the region explicitly.

MyMatcher.region(MyMatcher.regionStart(), end);

## Reset start to the default; set the end of the region explicitly.

MyMatcher.region(0, end);