Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
9.3
9.4
9.5
10.0
10.1
10.2
10.3
10.4
10.5
10.6
Statistic
FMM
Blog
RegEx.Replace
Replace pattern once.
| Component | Version | macOS | Windows | Linux | Server | FileMaker iOS SDK |
| RegEx | 7.5 | Yes | Yes | Yes | Yes | Yes |
MBS( "RegEx.Replace"; Text; Pattern; Rewrite { ; Options; All } ) More
Parameters
| Parameter | Description | Example | Flags |
|---|---|---|---|
| Text | The text to use. | "hello world" | |
| Pattern | The pattern to use. | "l+" | |
| Rewrite | The output pattern. | "\1\1" | |
| Options | The PCRE options. Can be given as text or number. |
0 | Optional |
| All | Whether to replace all occurances. Pass 1 to replace all or 0 to replace once. Default 0. |
0 | Optional |
Result
Returns new text or error.
Description
Replace pattern once.You can replace the first match of pattern in text with rewrite pattern. Within rewrite pattern, backslash-escaped digits (\1 to \9) can be used to insert text matching corresponding parenthesized group from the pattern. \0 in rewrite refers to the entire matching text.
| Option | Number | Description |
| Caseless | 1 | Do caseless matching |
| CaseSensitive | 0 | Do case sensitive matching |
| Multiline | 2 | ^ and $ match newlines within data |
| SingleLine | 0 | ^ and $ do not match newlines within data |
| DotAll | 4 | . matches anything including NL |
| Extended | 8 | Ignore white space and # comments |
| Anchored | 16 | Force pattern anchoring |
| DollarEndOnly | 32 | $ not to match newline at end |
| NotBOL | 128 | Subject string is not the beginning of a line |
| NotEOL | 256 | Subject string is not the end of a line |
| Ungreedy | 512 | Invert greediness of quantifiers |
| Greedy | 0 | Be greedy. |
| NotEmpty | 1024 | An empty string is not a valid match |
| Empty | 0 | An empty string is a valid match |
| AutoCapture | 0 | Enable numbered capturing parentheses |
| NoAutoCapture | 4096 | Disable numbered capturing parentheses (named ones available) |
| AutoCallout | 16384 | Compile automatic callouts |
| NoAutoCallout | 0 | Don’t compile automatic callouts |
| Partial | 32768 | Allow partial results. |
| FirstLine | 262144 | Force matching to be before newline |
| DupNames | 524288 | Allow duplicate names for subpatterns |
| NewlineCR | 1048576 | Set CR as the newline sequence |
| NewlineLF | 2097152 | Set LF as the newline sequence |
| NewlineCRLF | 3145728 | Set CRLF as the newline sequence |
| NewlineAny | 4194304 | Recognize any Unicode newline sequence |
| NewlineAnyCRLF | 5242880 | Recognize CR, LF, and CRLF as newline sequences |
| BSRAnyCRLF | 8388608 | \R matches only CR, LF, or CRLF |
| BSRUnicode | 16777216 | \R matches all Unicode line endings |
| JavaScriptCompatible | 33554432 | JavaScript compatibility |
| NoStartOptimize | 67108864 | Disable match-time start optimizations |
| PartialHard | 134217728 | Return partial result if found before . |
| NotEmptyAtStart | 268435456 | An empty string at the start of the subject is not a valid match |
| UCP | 536870912 | Use Unicode properties for \d, \w, etc. |
Examples
Replace:
MBS( "RegEx.Replace"; "yabba dabba doo"; "b+"; "d" )
Example result: "yadba dabba doo"
See also
Blog Entries
Release notes
- Version 7.5
- Added RegEx.Replace, RegEx.ReplaceAll and RegEx.Quote functions.
Created 17th October 2017, last changed 17th October 2017
RegEx.Quote - RegEx.ReplaceAll
Feedback: Report problem or ask question.
Links
MBS Xojo Plugins