Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Stripping RTF characters from Database Field but preserving the "\par" markings.

Posted on 2012-03-23
7
Medium Priority
?
933 Views
Last Modified: 2012-03-23
Need a way to keep "\par" but remove everything else.  Two samples below..one before stripping out RTF and the other is after.  

How would I either leave "\par" in but remove everything else or find the position of "\par" before removing RTF then put them back (more than one).

Thanks,
SISDalia


Original Field before stipping out RTF

{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\froman\fprq2 Times New Roman;}{\f3\froman Times New Roman;}{\f4\froman Times New Roman;}{\f5\fswiss MS Sans Serif;}}
{\colortbl\red0\green0\blue0;}
\deflang1033\pard\plain\f2\fs24 I am pleased to offer this Medical Student Performance Evaluation for Habibollah S. Alamdari as a candidate for your post-graduate training program.  Habibollah was born and raised in California, to a father who was a mechanic and a mother who was a substitute teacher.  His parents divorced at a young age and he was raised by his mother with limited finances and in a difficult neighborhood.  When his mother remarried he became the eldest of eight siblings, and he learned the necessity of hard work, devotion, and a positive outlook on life.
\par
\par Habibollah spent his formative years in Palmdale, California, where he excelled, moving to the top of his class and graduating as Salutatorian.  As a youth he developed an eye for both the arts and the sciences, leading him to excel in honors courses in Fine Arts and Biology.  He developed and painted murals for his school, was a student leader for the California Scholarship Federation, and excelled in both Cross Country and Wrestling for his high school.
\par
\par Habibollah attended California State University Northridge where he majored in Graphic Design and graduated \plain\f2\fs24\i magna cum laude\plain\f2\fs24 .  He was the president for the Community Medicine group, an active member in the CSUN Peer Helpline, and he spearheaded a program to create a mural at a local elementary school.  He was awarded several scholarships and assisted in research on neural crest cell migration.
\par
\par While in medical school, Habibollah has continued to distinguish himself as both an artist, a researcher, and dedicated member of his community.  He developed a short film that won him an Audience Award at a comedy festival in Los Angeles.  Habibollah continued to explore his interest in research and his work studying drug reactions in patients has led to a first-author publication in a peer reviewed journal and a 2nd place prize at the regional American College of Physicians conference.  He also volunteered his time at the UCLA student run homeless clinic and at the Venice Family Clinic to work with the underserved populations of Los Angeles. He has now completed several research projects with Dermatology faculty at UCLA as well as Wake Forest and the Univeristy of Missouri, the majority of which have been submitted for publication. He has further distinguished himself with a \plain\f2\fs24\b USMLE Step 1 score of 231.
\par \plain\f3\fs24
\par }


Field after stripping out RTF

I am pleased to offer this Medical Student Performance Evaluation for Habibollah S. Alamdari as a candidate for your post-graduate training program. Habibollah was born and raised in California, to a father who was a mechanic and a mother who was a substitute teacher. His parents divorced at a young age and he was raised by his mother with limited finances and in a difficult neighborhood. When his mother remarried he became the eldest of eight siblings, and he learned the necessity of hard work, devotion, and a positive outlook on life. Habibollah spent his formative years in Palmdale, California, where he excelled, moving to the top of his class and graduating as Salutatorian. As a youth he developed an eye for both the arts and the sciences, leading him to excel in honors courses in Fine Arts and Biology. He developed and painted murals for his school, was a student leader for the California Scholarship Federation, and excelled in both Cross Country and Wrestling for his high school. Habibollah attended California State University Northridge where he majored in Graphic Design and graduated magna cum laude. He was the president for the Community Medicine group, an active member in the CSUN Peer Helpline, and he spearheaded a program to create a mural at a local elementary school. He was awarded several scholarships and assisted in research on neural crest cell migration. While in medical school, Habibollah has continued to distinguish himself as both an artist, a researcher, and dedicated member of his community. He developed a short film that won him an Audience Award at a comedy festival in Los Angeles. Habibollah continued to explore his interest in research and his work studying drug reactions in patients has led to a first-author publication in a peer reviewed journal and a 2nd place prize at the regional American College of Physicians conference. He also volunteered his time at the UCLA student run homeless clinic and at the Venice Family Clinic to work with the underserved populations of Los Angeles. He has now completed several research projects with Dermatology faculty at UCLA as well as Wake Forest and the Univeristy of Missouri, the majority of which have been submitted for publication. He has further distinguished himself with a USMLE Step 1 score of 231.
0
Comment
Question by:SISDalia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37758093
What do you need for the \par elements to be (carriage return, line feed)?

I would suggest transforming the text, and replace the \par with something that doesn't
get recognized as an RTF element, like a carriage return/line feed.

Or, replacing \par with character 127, and then changing it back to \par, after stripping out the other RTF tags.
0
 

Author Comment

by:SISDalia
ID: 37758446
very smart idea. Let me try that! Thanks.
0
 

Author Comment

by:SISDalia
ID: 37758515
So here is what I tried but it isn't working? What am I missing?
Does <p> also get stripped out?

Function StripOutRichText(ByVal strRTF As String)

 
    If strRTF.StartsWith("{\rtf") Then 'Or strRTF.EndsWith "}" Then

      Dim worker As New RichTextBox()
      strRTF.Replace("\par", "<p>")
      worker.Rtf = strRTF
      Return worker.Text
   End If
   strRTF.Replace("<p>", "\par")
   
   Return strRTF

End Function
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 37758557
I would try to replace it with a unique sequence, like "{{Paragraph}}", and then change it back.
0
 

Author Comment

by:SISDalia
ID: 37759064
Now the \par \par is showing up between the text and not actually formatting it.

I'm using a text area to display the field.  is \par the right thing to use for a new line with a text area?

 <textarea id="txtUniqueChar" runat="server" class="editor" rows="25" cols="110" data-prop="UniqueCharacter">&nbsp;</textarea>
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 300 total points
ID: 37759073
For HTML that would be a <br> element.  For Windows Forms, that would be carriage return/line feed.
0
 

Author Comment

by:SISDalia
ID: 37759293
Thanks..that worked.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question