<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "JavaScriptCore",
  "identifier" : "/documentation/JavaScriptCore/JSValue/init(newRegularExpressionFromPattern:flags:in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:objc(cs)JSValue(cm)valueWithNewRegularExpressionFromPattern:flags:inContext:"
  },
  "title" : "init(newRegularExpressionFromPattern:flags:in:)"
}
-->

# init(newRegularExpressionFromPattern:flags:in:)

Creates a JavaScript regular expression value from the specified pattern.

```
init!(newRegularExpressionFromPattern pattern: String!, flags: String!, in context: JSContext!)
```

## Parameters

`pattern`

A string to be interpreted as a regular expression pattern.

`flags`

A combination of zero or more single-letter flags specifying search options.

`context`

The JavaScript context in which to create the value.

## Return Value

A new JavaScript regular expression object.

## Discussion

Calling this method creates a JavaScript `RegExp` object, and is equivalent to declaring a regular expression literal (such as `/ab+c/i`) or calling the `RegExp` constructor (for example, `new RegExp("ab+c", "i")`) in JavaScript.

The `flags` parameter can include any of the following options:

- `g` (global match): match all occurrences of the pattern in a string, not just the first.
- `i` (ignore case): perform case-insensitive search.
- `m` (multiline): treat the `^` and `$` regular expression tokens as matching the start or end of any line in a string (as delimited by newline or return characters), not just the start or end of the entire string.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)