2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,13 +1,11 @@
|
|||
/*REXX program demonstrates removal of 1st/last/1st&last chars from a string. */
|
||||
/*REXX program demonstrates removal of 1st/last/1st-and-last characters from a string.*/
|
||||
@ = 'abcdefghijk'
|
||||
say ' the original string =' @
|
||||
say 'string first character removed =' substr(@,2)
|
||||
say 'string last character removed =' left(@,length(@)-1)
|
||||
say 'string first & last character removed =' substr(@,2,length(@)-2)
|
||||
/*stick a fork in it, we're all done. */
|
||||
|
||||
/* ╔═══════════════════════════════════════════════════════╗
|
||||
║ However, the original string may be null or exactly ║
|
||||
║ one byte in length which will cause the BIFs to ║
|
||||
║ fail because of either zero or a negative length. ║
|
||||
╚═══════════════════════════════════════════════════════╝ */
|
||||
say 'string first character removed =' substr(@, 2)
|
||||
say 'string last character removed =' left(@, length(@) -1)
|
||||
say 'string first & last character removed =' substr(@, 2, length(@) -2)
|
||||
/*stick a fork in it, we're all done. */
|
||||
/* ╔═══════════════════════════════════════════════════════════════════════════════╗
|
||||
║ However, the original string may be null or exactly one byte in length which ║
|
||||
║ will cause the BIFs to fail because of either zero or a negative length. ║
|
||||
╚═══════════════════════════════════════════════════════════════════════════════╝ */
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
/*REXX program demonstrates removal of 1st/last/1st&last chars from a string. */
|
||||
/*REXX program demonstrates removal of 1st/last/1st-and-last characters from a string.*/
|
||||
@ = 'abcdefghijk'
|
||||
say ' the original string =' @
|
||||
say 'string first character removed =' substr(@,2)
|
||||
say 'string last character removed =' left(@,max(0,length(@)-1))
|
||||
say 'string first & last character removed =' substr(@,2,max(0,length(@)-2))
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
say 'string first character removed =' substr(@, 2)
|
||||
say 'string last character removed =' left(@, max(0, length(@) -1))
|
||||
say 'string first & last character removed =' substr(@, 2, max(0, length(@) -2))
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
|
||||
/* [↓] an easier to read version using a length variable.*/
|
||||
/* [↓] an easier to read version using a length variable.*/
|
||||
@ = 'abcdefghijk'
|
||||
L=length(@)
|
||||
say ' the original string =' @
|
||||
say 'string first character removed =' substr(@,2)
|
||||
say 'string last character removed =' left(@,max(0,L-1))
|
||||
say 'string first & last character removed =' substr(@,2,max(0,L-2))
|
||||
say 'string first character removed =' substr(@, 2)
|
||||
say 'string last character removed =' left(@, max(0, L-1) )
|
||||
say 'string first & last character removed =' substr(@, 2, max(0, L-2) )
|
||||
|
|
|
|||
|
|
@ -1,16 +1,15 @@
|
|||
/*REXX program demonstrates removal of 1st/last/1st&last chars from a string. */
|
||||
/*REXX program demonstrates removal of 1st/last/1st-and-last characters from a string.*/
|
||||
@ = 'abcdefghijk'
|
||||
say ' the original string =' @
|
||||
|
||||
parse var @ 2 z
|
||||
say 'string first character removed =' z
|
||||
|
||||
m=length(@)-1
|
||||
m=length(@) - 1
|
||||
parse var @ z +(m)
|
||||
say 'string last character removed =' z
|
||||
|
||||
n=length(@)-2
|
||||
n=length(@) - 2
|
||||
parse var @ 2 z +(n)
|
||||
if n==0 then z= /*handle special case of a length of 2.*/
|
||||
say 'string first & last character removed =' z
|
||||
/*stick a fork in it, we're all done. */
|
||||
if n==0 then z= /*handle special case of a length of 2.*/
|
||||
say 'string first & last character removed =' z /*stick a fork in it, we're all done. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue