Rohan Posted October 6, 2021 Share Posted October 6, 2021 Was having trouble with the transform/replace function. Was wondering if I have a signal that produces strings, how I can replace the last two or three digits depending on the size of the string. If the string is 22 characters long, I want to remove the last two digits, while if the string is 23 characters long I want to remove the last 3 characters. For example, if the string is 000000000-000-00BRX111-2, want to remove just the -2 part. Thanks Link to comment Share on other sites More sharing options...
Thorsten Vogt Posted October 6, 2021 Share Posted October 6, 2021 Hi Rohan, you can use the replace() function for this: $signal.replace('/(.{22}).*/', '$1') The snippet takes the first 22 characters and replaces the original value of the signal with the characters captured. Regards, Thorsten Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now