# Fragments class

Namespace: [Grasshopper2.Parsing](https://developer.rhino3d.com/api/gh2/namespace/grasshopper2.parsing.md) · Assembly: [Grasshopper2](https://developer.rhino3d.com/api/gh2/assembly/grasshopper2.md)

```cs
public sealed class Fragments : IEnumerable<Fragment>
```

A string split into categorised fragments, plus the views derived from it.

Scanning happens once, on creation, and never fails. Problems such as an unterminated literal or an unmatched bracket are recorded on the fragment they belong to, so that half typed input still yields a complete and navigable result. Call [Fragments.Validate()](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/validate.md) when well formed input is required.

Every view is pinned to the same [Fragments.Source](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/source.md) string and every fragment reports absolute indices into it, so error positions remain valid no matter how deeply a view is derived.

## Properties

- [Body](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/body.md): Gets all fragments in this view except the two terminals. This is what interpreters pattern match against. Do not modify the returned array.
- [Count](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/count.md): Gets the number of fragments in this view, including the two terminals.
- [First](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/first.md): Gets the first fragment which is neither a terminal nor trivia, or the tail marker when there is no such fragment.
- [Head](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/head.md): Gets the marker at the start of this view.
- [InnerContent](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/innercontent.md): Gets this view without any enclosing bracket pairs. The cleanup is repeated, so that "([5])" yields "5". Returns this view when the body is not wrapped in a bracket pair.
- [Options](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/options.md): Gets the choices this view was scanned with. Views inherit the options of the collection they were derived from, since they describe the same characters.
- [OuterBrackets](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/outerbrackets.md): Gets the opening bracket of the innermost pair removed by [Fragments.InnerContent](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/innercontent.md), or null when this view is not wrapped. Access the corresponding closing bracket via [BracketFragment.Partner](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.bracketfragment/partner.md).
- [Reduced](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/reduced.md): Gets a view without whitespace or comments. Line breaks are retained.
- [Source](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/source.md): Gets the string these fragments were scanned from. This is the complete string in every view, never a substring of it.
- [Tail](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/tail.md): Gets the marker at the end of this view.

## Indexers

- [this[]](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/item.md): Gets the fragment at the given index.

## Methods

- [After](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/after.md): Create a view of everything following the given fragment.
- [Before](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/before.md): Create a view of everything preceding the given fragment.
- [BreakLines](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/breaklines.md): Create one view per line. The line breaks themselves are omitted; they are the delimiters. A bracket pair split across two lines loses track of itself, and both sides will report a null partner.
- [Content](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/content.md): Gets the source text from the first meaningful fragment of this view to the last, which is [Fragments.Coverage()](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/coverage.md) without the whitespace and comments around the outside of it. A view holding nothing but trivia yields an empty string, which is how a piece of a split can say it carries no content at all.
- [Coverage](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/coverage.md): Gets the characters spanned by this view. Unlike [Fragments.Source](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/source.md), which is always the complete string, this covers only the extent between the two terminals.
- [Create](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/create.md): (static) Split a string into fragments.
- [Find](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/find.md): Find every fragment matching the predicate which sits at the top level of this view, that is, inside none of its bracket pairs.
- [GetEnumerator](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/getenumerator.md): Enumerate every fragment in this view, terminals included.
- [Segment](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/segment.md): Create a view of a run of this view's fragments, both ends included.
- [Split](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/split.md): Cut this view into pieces at every top level occurrence of a symbol. The separators themselves are omitted, and a view without any separators yields a single piece, so the result always holds one more piece than there were separators.
- [IEnumerable.GetEnumerator](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/system-collections-ienumerable-getenumerator.md)
- [ToString](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/tostring.md): Gets a description of this view, for debugging purposes.
- [Validate](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/validate.md): Report the first defect in this view, if there is one.
- [Without](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/without.md): Create a view without the fragments matching the given mask.
