Answered

Using Substring to remove multiple characters from the end of a text string.

I would like to know how to remove multiple characters from the end of a text string, for example..

Before - https://apps.test.era.nih.gov/rcdc/endpoints.era

After - https://apps.test.era.nih.gov/rcdc

...I read https://subject7.zendesk.com/hc/en-us/community/posts/360050236354-Substring-command and it is not helpful since the flow of the Substring command is from left to right/first to last character and not be reversed (Feature request to have this option). 

This is not part of a element that I could use the GET_WEB_VALUE command with the Characters to Exclude option, and the Get_Current_URL command does not have the Characters to Exclude option (Feature request to have this option). 

 

Thanks.

0
1 comment
Avatar
Joseph Hamdan

Hi Stephen,

You can use Get_Web_Value command with Javascript option (no locator required) and enter the below:

const str = "https://apps.test.era.nih.gov/rcdc/endpoints.era";

const str2 = str.substring(0, str.length - 14);

return str2

In the first line, the value here is static but can always be pointed to a variable from Get_Current_URL command. For example:

const str = "@url";

Regards,
Subject7 Team

0
Comment actions Permalink

Please sign in to leave a comment.