'Partial text assertion and compare of 2 variables in selenium ide

I'm having a problem that I'm not sure how to solve. I have a customer code on one page (ex. Test095). I store it as var1. And I have to navigate to another page and verify that the code is the same. But on the second page the customer code looks like this : Customer Code: Test095. I store is as var2. So I have to remove Customer Code words from here , so I can verify that var1 equals var2. How can I get rid of Customer Code words?

open |www.link.com
verify title | Page
assert text| css=tr:child(1)-example | Test095
store | css=tr:child(1)-example | var1
open |www.anotherlik.com 
assert text| xpath = //div[@id='myform']/div/div/p[4] | Customer code: Test095
store|xpath = //div[@id='myform']/div/div/p[4] |var2
verify| var2    | ${var1}


Solution 1:[1]

use java inbuit replace() function for string. Its better also to use trim incase to remove whitespaces

 String s = "Customer Code: Test095";
 s = s.replace("Customer Code:","").trim();
 System.out.println(s);

To make this work in Selenium IDE use command 'execute script', as i used in screenshot below

enter image description here

Here 'y' will store value Test095

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1