> For the complete documentation index, see [llms.txt](https://docs.verygoodsecurity.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.verygoodsecurity.com/vault/developer-tools/vgs-show/ios-sdk/samples.md).

# Samples

### VGS Show iOS SDK Samples

Check samples and code examples how to use VGS Show SDK features.

### Text Formatting in VGSLabel

You have an option to transform the revealed text with specified pattern in `addTransformationRegex(_:)` function.

#### Code example

```swift
/// Option 1. Card Number formatting
// Create regex object, split card number to XXXX XXXX XXXX XXXX format.
let cardNumberPattern = "(\\d{4})(\\d{4})(\\d{4})(\\d{4})"
let template = "$1 $2 $3 $4"

// Use force try! here for sample.
let regex = try! NSRegularExpression(pattern: cardNumberPattern, options: [])

// Add transformation regex and template to your label.
cardNumberLabel.addTransformationRegex(regex, template: template)

/// Option 2. Social Security Number formatting
// Create regex object, split SSN to XXX-XX-XXXX format.
let ssnPattern = "(\\d{3})(\\d{2})(\\d{4})"
let template = "$1 $2 $3"

// Use force try! here for sample.
let regex = try! NSRegularExpression(pattern: ssnPattern, options: [])

// Add transformation regex and template to your label.
ssnLabel.addTransformationRegex(regex, template: template)
```

### Secure text in VGSLabel

You can hide revealed text with `secureTextSymbol` fully or partially. Check the code examples how to add an option for your users to show/hide revealed data.

#### Code example

```swift
// Revealed Data
4111111111111111

// Displayed string in VGSLabel after modification with transformation regex
4111-1111-1111-1111

// Option 1. Secure all text in VGSLabel
label.isSecureText = true // => "*******************"

// Option 2. Change secure symbol
label.secureTextSymbol = "x" // => "xxxxxxxxxxxxxxxxxxx"

// Option 3. Secure text from 4th character
label.setSecureText(start: 4) // => "4111xxxxxxxxxxxxxxx"

// Option 4. Secure text till 15th character
label.setSecureText(end: 14) // => "xxxxxxxxxxxxxxx1111"

// Option 5. Secure text from 4th till 14th characters
label.setSecureText(start: 4, end: 14) // => "4111xxxxxxxxxxx1111"

// Option 6. Secure text in ranges [5,8] & [10, 13]
let range1 = VGSTextRange(start: 5, end: 8)
let range2 = VGSTextRange(start: 10, end: 13)
label.setSecureText(ranges: [range1, range2]) // => "4111-xxxx-xxxx-1111"
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.verygoodsecurity.com/vault/developer-tools/vgs-show/ios-sdk/samples.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
