Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 872657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:49:02+00:00 2026-05-15T10:49:02+00:00

When using a multi-line TextBox (AcceptsReturn=True) in Silverlight, line feeds are recorded as \r

  • 0

When using a multi-line TextBox (AcceptsReturn=”True”) in Silverlight, line feeds are recorded as \r rather than \r\n. This is causing problems when the data is persisted and later exported to another format to be read by a Windows application.

I was thinking of using a regular expression to replace any single \r characters with a \r\n, but I suck at regex’s and couldn’t get it to work.

Because there may be a mixture of line endings just blindy replacing all \r with \r\n doesn’t cut it.

So two questions really…

If regex is the way to go what’s the correct pattern?

Is there a way to get Silverlight to respect it’s own Environment.NewLine character in TextBox’s and have it insert \r\n rather just a single \r?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:49:03+00:00Added an answer on May 15, 2026 at 10:49 am

    I don’t know Silverlight, but I imagine (I hope!) there’s a way to get it to respect Environment.NewLine—that would be a better approach. If there isn’t, however, you can use a regex. I’ll assume you have text which contains all of \r, \n, and \r\n, and never uses those as anything but line endings—you just want consistency. (If they show up as non-line ending data, the regex solution becomes much harder, and possibly impossible.) You thus want to replace all occurrences of \r(?!\n)|(?<!\r)\n with \r\n. The first half of the first regex matches any \r not followed by a \n; the second half matches a lone \n which wasn’t preceded by a \r.

    The fancy operators in this regex are termed lookaround: (?=...) is a positive lookahead, (?<=...) is a positive lookbehind, (?!...) is a negative lookahead, and (?<!...) is a negative lookbehind. Each of them is a zero-width assertion like ^ or $; they match successfully without consuming input if the given regex succeeds/fails (for positive/negative, respectively) to match after/before (for lookahead/lookbehind) the current location in the string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to have a multi-line textbox (im using asp.net c#) where the
I am writing text to a multi-line text box using data from the serial
I'm trying to prepend a string a read-only, multi-line TextBox using the following code:
I am trying to create a multi dimensional array using this syntax: $x[1] =
I am trying to match a multi line text using Java. When I use
I want to type 140 characters in asp.net textbox with multi line when I
I am using a multi-dimensional dynamic array in delphi and am trying to figure
A legacy embedded system is implemented using a cooperative multi-tasking scheduler. The system essentially
I'm playing around with LinqToSQL using an existing multi-lingual database, but I'm running into
Using Windows Server 2003 in a multi-user environment (via Remote Desktop, using it as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.