[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 941
  • Last Modified:

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

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
SISDalia
Asked:
SISDalia
  • 4
  • 3
1 Solution
 
Bob LearnedCommented:
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
 
SISDaliaAuthor Commented:
very smart idea. Let me try that! Thanks.
0
 
SISDaliaAuthor Commented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Bob LearnedCommented:
I would try to replace it with a unique sequence, like "{{Paragraph}}", and then change it back.
0
 
SISDaliaAuthor Commented:
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
 
Bob LearnedCommented:
For HTML that would be a <br> element.  For Windows Forms, that would be carriage return/line feed.
0
 
SISDaliaAuthor Commented:
Thanks..that worked.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now