- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2018 07:59 AM
Hello,
How would I script removing all characters from a string ONLY if it is followed by a hyphen? I do not want the characters removed if the hyphen is not at the end.
Example: hello- (should return null)
OR
hello (should return hello since there is not a hyphen)
Thanks!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2018 10:26 AM
For this example, our source column is called User ID, which is the equivilant of u_user_id. Feel free to change the source field to whatever the source field is for your import. Taking the function Michael used, I have created the script that you can use for the user_name target field (I am guessing that this is the target field):
answer = (function transformEntry(source) {
var chkString = source.u_user_id.toString();
if (chkString.endsWith('-D')){
return '';
} else {
return chkString;
}
})(source);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2018 10:26 AM
For this example, our source column is called User ID, which is the equivilant of u_user_id. Feel free to change the source field to whatever the source field is for your import. Taking the function Michael used, I have created the script that you can use for the user_name target field (I am guessing that this is the target field):
answer = (function transformEntry(source) {
var chkString = source.u_user_id.toString();
if (chkString.endsWith('-D')){
return '';
} else {
return chkString;
}
})(source);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2018 10:30 AM
Thanks all! This worked perfect.