Remove text/characters between 2 identifiers

  • 11 September 2018
  • 6 replies
  • 4 views

Badge +6

I have a workflow that pulls text from a multi-line append text field.  I have everything working, except if a user copies and pastes data from another application into the field on the form.  When that happens, span class and font tags are embedded into the comment string.

I am looking for a solution, using Regular Expression, to remove the span and font tags, but leave the text within those tags, so I have a complete comment.

Example:

needs feedback if <span style="font-family:"calibri",sans-serif;font-size:11pt;"><font color="#000000">maintenance, support and service fees</font></span> are involved and...

I need to remove the everything in Red font, so the out looks like:

needs feedback if maintenance, support and service fees are involved and...

Thank you!


6 replies

Userlevel 5
Badge +13

The timing of your question is great because I was working on a solution for this today. It can be achieved via workflow using Regular Expression actions. I'm using Nintex Workflow 2013.

To remove all the tags related to the SPAN and FONT, you'll need four Regular Expression actions. You can order them in any way, but here's the order that worked for me.

  1. Insert a Regular Expression to remove the beginning SPAN tags. Store the result in multi-line text variable (for example, varContent). The Pattern in Regular Expression action should be:   <span[^>]+>
  2. Insert a Regular Expression to remove the ending SPAN tags. The Input Text should be the multi-line text variable (varContent). Store the result in the same multi-line text variable (varContent). The Pattern in Regular Expression action should be:   </span>
  3. Insert a Regular Expression to remove the beginning FONT tags. The Input Text should be the multi-line text variable (varContent). Store the result in the same multi-line text variable (varContent). The Pattern in Regular Expression action should be:   <font[^>]+>
  4. Insert a Regular Expression to remove the ending FONT tags. The Input Text should be the multi-line text variable (varContent). Store the result in the same multi-line text variable (varContent). The Pattern in Regular Expression action should be:   </font>


This should remove all the SPAN and FONT tags from your text. You can use the Run Now button in the Regular Expression action to test these out.

Userlevel 5
Badge +14

if you do not expect any valid substring surrounded with angle brackets you can simplify regular expression like follows.

it will take care of any opening or closing tag at once happy.png

<[^>]+>‍‍

219117_pastedImage_1.png

Badge +6

Thank you both very much!!!  That seems to have done the trick: <[^>]+>

I do have some concerns, but not sure if this change is causing it, or something else is causing it.  When new comments are added, the oldest comment is being deleted from the comments box (multi-line text box w append changes).  I didn't think there was a limit, to the amount of comments, and I know there are records with a lot of appended comments, and none were deleted before.

Since I incorporated the change, I have 2 records that it is deleting the oldest comment.

Comment history for 1 record, after running the incorporated change on the workflow:

User3 (9/13/2018 8:27 AM):
Comment

User3 (9/10/2018 10:29 AM):
Comment

User3 (9/6/2018 10:19 AM):
Comment

User3 (9/5/2018 1:49 PM):
Comment

User2 (8/23/2018 2:16 PM):
Comment

User1(6/27/2018 10:46 AM):
Comment

User1 (6/25/2018 11:10 AM):
Comment

What is stored in the new comment field after the workflow is run:

User3 : 2018-09-13 08:27:56 : Comment 

;User3 : 2018-09-10 10:29:09 : Comment

;User3 : 2018-09-06 10:19:39 : Comment

;User3 : 2018-09-05 01:49:38 : Comment

;User2 : 2018-08-23 02:16:09 : Comment

;User1 : 2018-06-27 10:46:49 : Comment

;User1 : 2018-06-25 11:10:55 : Comment 

;User1 : 2018-06-13 03:42:53 : Comment ;  This comment is no longer included in the Comment Text box on the form.  I'm afraid the next time a comment is entered on this record, this comment will no longer exist and therefore not be loaded into the new comment field.  (***My workflow clears out the new comment field each time it runs...so historical data is not saved...not sure how to rework the workflow to just append the newest comment to the existing data).

Any idea what could be causing the oldest comments to be deleted from the comment field on the form?

Userlevel 4
Badge +11

Could you check how many version are set in your list/library versioning settings? I think that this may be related..

Badge +6

Hi Giacomo,

I have a screen shot below of the Versioning Settings screen.  I believe it looks like 15 versions.  So, would that mean, after 15 comments are added it would start dropping them off?  Or would it be after 15 times of going into the request to make any sort of edit, it would start losing the history?  The earlier scenario only had 8 comments when it ran and deleted the oldest one.

Thank you!!

Userlevel 5
Badge +14

it's item level version history, so it keeps track of 15 recent item changes regardless of whether you changed appendable field or not.

Reply