SS

Hello Everyone,

I've been trying to clear a string from the HTML tags contained in it. Below is the code, I tried:


var oRegExp =  new RegExp('/\/?[^>]+(>|$)/', 'g');
retrievedExtDesc = retrievedExtDesc.replace(oRegExp, '');



But this is the error, I get:





I tried using double quotation marks also. I tried removing the single quotation mark from the letter g in the RegExp constructor, but that did not help - I get another error - g not recognised or something, if I do that.



I'd appreciate any suggestions. Thanks!

 

by Stefano Pulliero
Posted on Fri, 04/26/2019 - 08:13

Hi,

i find the same error when i try to apply RegEx. the problem is that you must cast regex expression so it's works

Bye

 

0
by Kay Fischbach
Posted on Mon, 05/06/2019 - 16:22

The error message tells you that you are trying to mix Java and Javascript

It tells you that you are trying to use the Java method java.lang.String.replace and as arguments you want to give it two arguments that are only acceptable in Javascript methods.

You probably assumed that something like

objectDefinitionObject.Attribute(Constants.AT_DESC, nLocale).getHTMLFormattedValue().getHTML();

would return you a Javascript string, for which you could use the Javascript .replace function. Nah, that's not how this works. Go to your ARIS Script help, open the webpage for the .getHMTL() method and click on the link of the returned object type. It will bring you to the Java API documentation, meaning you get a Java String as a returned value.

What to do now you may ask? Well Java Strings have a method called replaceAll and it's used like this:

var descHTMLString = selDef.Attribute(Constants.AT_DESC, nLocale).getHTMLFormattedValue().getHTML();

var filterdString = descHTMLString.replaceAll("<.*?>", "");

The regular expression is pretty simple

  1. Look for strings that start with <
  2. after that match any character as few times as you can
  3. until you find a >

With replaceAll you can find many individual matches in your given html String, and replace them with empty strings, leaving behind just the thing that wasn't enclosed in < >.

0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock