Solved

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

Posted on 2012-03-23
7
925 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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 75 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert VBA UDF to SQl SERVER UDF 4 49
SQL syntax question 6 41
Specify timing interval fro change data 2 54
CSS for Popup in ASP.NET 4 16
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how the fundamental information of how to create a table.

749 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