- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
question on right function
Trying to use Right function as below in my jsl code
dt << New Column("ORIG_MARK",Character,Nominal,Formula(Right(:result,(Contains(:result,"_",3)))));
The result of this statement is as below,but I intend to eliminate the "_" from every row in the ORIG_MARK column.How can I modify the above statement to accomplish this?
result | ORIG_MARK |
ORIG_MARK_A | _A |
ORIG_MARK_B | _B |
ORIG_MARK_C | _C |
ORIG_MARK_D | _D |
ORIG_MARK_E | _E |
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: question on right function
Right(str, n) will return you right n characters of str. Contains(str, pattern, n) will return you first index of pattern in str starting from n. If you want to get string after last "_" I would use Word() or Substitute() to remove "ORIG_MARK_". If you want to use Right(), you will have to calculate the length of string you want get for example by using combination of Length() and Contains().
Here is one option using Word():
Word(-1, :result, "_")
See Scripting Index for examples.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: question on right function
Right(str, n) will return you right n characters of str. Contains(str, pattern, n) will return you first index of pattern in str starting from n. If you want to get string after last "_" I would use Word() or Substitute() to remove "ORIG_MARK_". If you want to use Right(), you will have to calculate the length of string you want get for example by using combination of Length() and Contains().
Here is one option using Word():
Word(-1, :result, "_")
See Scripting Index for examples.