Text.ReplaceNewLine
-------------------

Replaces newline characters.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Text](component_Text.md) | [2.4](newinversion24.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Text.ReplaceNewLine"; Text; Mode { ; Wrap } ) 

**MBS**( **"Text.ReplaceNewLine";** /\* Replaces newline characters. \*/  
**$Text**; /\* The text to process.e.g. "Hello World" \*/   
**$Mode**; /\* The operation mode. First a value for the output newline type:   
0: nothing  
1: CR (Mac)  
2: LF (Unix)  
3: CRLF (Windows)  
4: &lt;br&gt; for html  
5: &lt;br /&gt; for xml  
  
Second you can add 8 to remove duplicate newlines. \*/   
**$Wrap**) /\* Optional; Optional whether to wrap lines longer than given number of characters. Default is 0 for no wrap.e.g. 80 \*/ 

(old name: String.ReplaceNewline)

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Text | The text to process. | "Hello World" |  |
| Mode | The operation mode. First a value for the output newline type:    0: nothing   1: CR (Mac)   2: LF (Unix)   3: CRLF (Windows)   4: &lt;br&gt; for html   5: &lt;br /&gt; for xml      Second you can add 8 to remove duplicate newlines. |  |  |
| Wrap | Optional whether to wrap lines longer than given number of characters. Default is 0 for no wrap. | 80 | Optional |

### Result

Text with modified newline characters.

### Description

Replaces newline characters.   
Can remove, convert to Mac, Windows and Linux specific end of line characters. Also can remove duplicates.  
FileMaker uses Mac line endings on all platforms.  
  
Like ReplaceLineEndings in Xojo to replace line breaks.  
This function works on pure text, so any text style is lost. And it truncates on first NULL byte.  
### Examples

Remove newlines from field:

 MBS ( "Text.ReplaceNewline"; Test Database::TextField ; 0 )  
Replaces newlines from field with Mac newlines:

 MBS ( "Text.ReplaceNewline"; Test Database::TextField ; 1 )  
Replaces newlines from field with Mac newlines and remove duplicates:

 MBS ( "Text.ReplaceNewline"; Test Database::TextField ; 1+8 )  
Write UTF-8 CRLF file:

 Set Variable \[ $text ; Value: "Joe,1234 Main St.¶John Glen,3132 Elm¶Johnson,5233 Wreybird¶Ray,263 Birch¶äöü" \]   
Set Variable \[ $path ; Value: "/Users/cs/Desktop/test.txt" \]   
Set Variable \[ $text ; Value: MBS ( "Text.ReplaceNewline"; $text ; 3) // CRLF \]   
Set Variable \[ $r ; Value: MBS ( "[Text.WriteTextFile](TextWriteTextFile.md)"; $text ; $path ; "UTF8" ) \]  
Change line endings for a text file:

 Set Variable \[ $path ; Value: "/Users/cs/Desktop/test.txt" \]   
Set Variable \[ $text ; Value: MBS ("[Text.ReadTextFile](TextReadTextFile.md)"; $path ; "UTF-8") \]   
Set Variable \[ $text ; Value: MBS ("Text.ReplaceNewline"; $text ; 3) \]  
\# 1 = CR for Mac   
\# 2 = LF for Linux   
\# 3 = CRLF for Windows   
Set Variable \[ $r ; Value: MBS ("[Text.WriteTextFile](TextWriteTextFile.md)"; $text ; $path ; "UTF-8") \]  
### See also

- [SendMail.SetHTMLText](SendMailSetHTMLText.md)
- [Shell.Execute](ShellExecute.md)
- [Shell.ReadOutputText](ShellReadOutputText.md)
- [Text.AppendTextFile](TextAppendTextFile.md)
- [Text.EncodeToHTML](TextEncodeToHTML.md)
- [Text.RemoveControlCharacters](TextRemoveControlCharacters.md)
- [Text.RemoveNewLine](TextRemoveNewLine.md)
- [Text.WriteTextFile](TextWriteTextFile.md)
- [WebRequest.GetRawData](WebRequestGetRawData.md)
- [WebRequest.Send](WebRequestSend.md)

### Example Databases

- [CURL/Email/Build and send Email](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/Build%20and%20send%20Email.shtml#1ScriptAnchor_)
- [CURL/Email/Build and send HTML Email with inline graphics](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/Build%20and%20send%20HTML%20Email%20with%20inline%20graphics.shtml#1ScriptAnchor_)
- [CURL/WebServices/Magento2 REST API](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/WebServices/Magento2%20REST%20API.shtml#1ScriptAnchor_)
- [CURL/WebServices/Twilio API Send SMS Json](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/WebServices/Twilio%20API%20Send%20SMS%20Json.shtml#1ScriptAnchor_)
- [Network/SSL/TCP Socket SSL](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Network/SSL/TCP%20Socket%20SSL.shtml#1ScriptAnchor_)
- [Third Party/Google OAUTH 2 example](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Third%20Party/Google%20OAUTH%202%20example.shtml#1ScriptAnchor_)
- [WebViewer/TinyMCE/TinyMCE](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/WebViewer/TinyMCE/TinyMCE.shtml#2ScriptAnchor_)

### Blog Entries

- [Filemaker: Export Text to File](https://www.mbsplugins.de/archive/2025-06-26/Filemaker_Export_Text_to_File/monkeybreadsoftware_blog_filemaker)
- [IMAP Upload Flags](https://www.mbsplugins.de/archive/2025-06-17/IMAP_Upload_Flags/monkeybreadsoftware_blog_filemaker)
- [Using Gmail with oAuth2 for SMTP with MBS Plugin](https://www.mbsplugins.de/archive/2025-05-08/Using_Gmail_with_oAuth2_for_SM/monkeybreadsoftware_blog_filemaker)
- [Extract invoice for ZUGFeRD and Facture-X](https://www.mbsplugins.de/archive/2024-09-20/Extract_invoice_for_ZUGFeRD_an/monkeybreadsoftware_blog_filemaker)
- [Trigger Scripts via WebHook](https://www.mbsplugins.de/archive/2022-12-08/Trigger_Scripts_via_WebHook/monkeybreadsoftware_blog_filemaker)
- [SMTP with OAuth for Office 365 in FileMaker](https://www.mbsplugins.de/archive/2022-11-22/SMTP_with_OAuth_for_Office_365/monkeybreadsoftware_blog_filemaker)
- [WebHook Introduction](https://www.mbsplugins.de/archive/2021-10-28/WebHook_Introduction/monkeybreadsoftware_blog_filemaker)
- [Sending email with a huge custom function](https://www.mbsplugins.de/archive/2021-06-26/Sending_email_with_a_huge_cust/monkeybreadsoftware_blog_filemaker)
- [Generate EPC-QR-Code in FileMaker](https://www.mbsplugins.de/archive/2021-01-26/Generate_EPC-QR-Code_in_FileMa/monkeybreadsoftware_blog_filemaker)
- [Import CSV with Matrix functions](https://www.mbsplugins.de/archive/2020-11-20/Import_CSV_with_Matrix_functio/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 6/2021, Seite 21](https://filemaker-magazin.de/neuigkeit/4165-Appetithappen-FMM_202106)
- [Ausgabe 5/2018, Seite 29](https://filemaker-magazin.de/neuigkeit/4011-Appetithappen-FMM_201805)
- [Ausgabe 5/2011, Seite 55](https://filemaker-magazin.de/neuigkeit/3506-Appetithappen-FMM_201105-06)

This function checks for a license.

Created 18th August 2014 , last changed 7th September 2025

  
[Text.ReplaceAll](TextReplaceAll.md) - [Text.Reverse](TextReverse.md)

[HTML Version](TextReplaceNewline.shtml)