|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.nitus.widgets.Strings
public class Strings
Strings
Creat per: Francesc Roses
Modificat per: Xavier Navarro
El dia 19-jul-04 a les 17:36:20
Projecte: Llibreries; Paquet: net.nitus.widgets
19/07/2004.- Funci� Strip. En lloc de fer servir un for, he
fet servir un while.
19/07/2004.- Funci� primeraMaj�scula.
The StringTools class contains several useful String functions from Rexx.
These functions are available from NetRexx (by Mike Cowlishaw as well as
Rexx) too. Rexx and NetRexx are very interesting languages. In NetRexx, these
string functions apply to Rexx strings not to java.lang.String
s. Frequently I need this useful functions to handle
java.lang.String
s. If I convert my strings to Rexx strings, I
apply the function and I convert the resulting Rexx string to
java.lang.String
I'll leave to use Rexx functions at second
attempt. So, I decided to code most of this functions from scratch as static
functions.
10/09/01: Strip returns an empty String ("") instead of null if the result string is empty. Creation date: (18/8/99 10:18:23)
Modified
copies(char, int)
if (times == 0) return null
becomes
[...] return ""
like in Rexx.copies(String, int)
if (times == 0) return ""
to do the same as in
copies(char, int)
.right(String, int, char)
if (len = s.length()) return s
.
Constructor Summary | |
---|---|
Strings()
|
Method Summary | |
---|---|
static java.lang.String |
center(java.lang.String s,
int len)
center(String,int) Returns a string of length len with s
centered in it, with pad characters added as necessary to make up
len . |
static java.lang.String |
center(java.lang.String s,
int len,
char pad)
center(String,int,char) Returns a string of length len with s
centered in it, with pad characters added as necessary to make up
len . |
static java.lang.String |
centre(java.lang.String s,
int len)
Returns a string of length len with s centered in it, with pad characters added as necessary to make up len. |
static java.lang.String |
centre(java.lang.String s,
int len,
char pad)
Returns a string of length len with s centered in it, with pad characters added as necessary to make up len. |
static java.lang.String |
changeStr(java.lang.String needle,
java.lang.String haystack,
java.lang.String newneedle)
changeStr(String, String, String) Replaces all occurrences of needle in haystack
with newneedle . |
static int |
compare(java.lang.String s1,
java.lang.String s2)
Returns -1 if the strings, string1 and string2, are identical. |
static int |
compare(java.lang.String s1,
java.lang.String s2,
char pad)
Returns -1 if the strings, string1 and string2, are identical. |
static java.lang.String |
copies(char c,
int times)
Autor: Francesc Ros�s Albiol Returns times concatenated copies of c . |
static java.lang.String |
copies(java.lang.String s,
int times)
Autor: Francesc Ros�s Albiol Returns times concatenated copies of c . |
static int |
countStr(java.lang.String needle,
java.lang.String haystack)
Returns a count of the occurrences of needle in haystack that do not overlap. |
static boolean |
dataType(java.lang.String value,
char type)
Checks if the string complies the type specification. |
static java.lang.String |
delStr(java.lang.String s,
int start)
Returns string after deleting the substring that begins at the nth character to the end (including the nth character). |
static java.lang.String |
delStr(java.lang.String s,
int start,
int len)
Returns string after deleting the substring that begins at the nth character and is of length characters. |
static java.lang.String |
delWord(java.lang.String s,
int start)
Returns string after deleting the substring that starts at the startth word. |
static java.lang.String |
delWord(java.lang.String s,
int start,
int len)
Returns string after deleting the substring that starts at the startth word and is of len blank-delimited words. |
static java.lang.String |
insert(java.lang.String snew,
java.lang.String target)
Inserts the string new into the string target. |
static java.lang.String |
insert(java.lang.String snew,
java.lang.String target,
int n)
Inserts the string new into the string target after the nth character. |
static java.lang.String |
insert(java.lang.String snew,
java.lang.String target,
int n,
int len)
Inserts the string new, padded or truncated to length len, into the string target after the nth character. |
static java.lang.String |
insert(java.lang.String snew,
java.lang.String target,
int n,
int len,
char pad)
Inserts the string new, padded or truncated to length len, into the string target after the nth character. |
static int |
lastPos(char needle,
java.lang.String haystack)
Calls the lastIndex method of String class. |
static int |
lastPos(char needle,
java.lang.String haystack,
int start)
Calls the lastIndex method of String class. |
static int |
lastPos(java.lang.String needle,
java.lang.String haystack)
Calls the lastIndex method of String class. |
static int |
lastPos(java.lang.String needle,
java.lang.String haystack,
int start)
Calls the lastIndex method of String class. |
static java.lang.String |
left(java.lang.String s,
int len)
Autor: Francesc Ros�s Albiol Returns the string s left aligned, len characters length and padded with blanks. |
static java.lang.String |
left(java.lang.String s,
int len,
char pad)
Autor: Francesc Ros�s Albiol Here are some examples:
left("1234", 2) - "12"
left("1234", 6) - "1234 "
left("1234", 6, '+') - "1234++"
Creation date: (18/8/99 10:19:58) |
static java.lang.String |
overlay(java.lang.String snew,
java.lang.String target)
Returns the string target, overlaid with the string snew from the beginning. |
static java.lang.String |
overlay(java.lang.String snew,
java.lang.String target,
int n)
Returns the string target, which, starting at the nth character, is overlaid with the string snew, padded or truncated to len length. |
static java.lang.String |
overlay(java.lang.String snew,
java.lang.String target,
int n,
int len)
Returns the string target, which, starting at the nth character, is overlaid with the string snew, padded or truncated to len length. |
static java.lang.String |
overlay(java.lang.String snew,
java.lang.String target,
int n,
int len,
char pad)
Returns the string target, which, starting at the nth character, is overlaid with the string snew, padded or truncated to len length. |
static int |
pos(char needle,
java.lang.String haystack)
Author: Xavier Navarro Ferrer Calls the index method of String class. |
static int |
pos(char needle,
java.lang.String haystack,
int start)
Author: Xavier Navarro Ferrer Calls the lastIndex method of String class. |
static int |
pos(java.lang.String needle,
java.lang.String haystack)
Author: Xavier Navarro Ferrer Calls the lastIndex method of String class. |
static int |
pos(java.lang.String needle,
java.lang.String haystack,
int start)
Author: Xavier Navarro Ferrer Calls the indexOf method of String class. |
static java.lang.String |
reverse(java.lang.String s)
Returns string, swapped end for end. |
static java.lang.String |
right(java.lang.String s,
int len)
Returns a string of length len containing the rightmost len characters of string. |
static java.lang.String |
right(java.lang.String s,
int len,
char pad)
Returns a string of length len containing the rightmost len characters of string. |
static java.lang.String |
space(java.lang.String s)
Returns the blank-delimited words in the receiving string, with one blank character between each word. |
static java.lang.String |
space(java.lang.String s,
char pad)
Returns the blank-delimited words in the receiving string, with one pad character between each word. |
static java.lang.String |
space(java.lang.String s,
int n)
Returns the blank-delimited words in the receiving string, with n blank characters between each word. |
static java.lang.String |
space(java.lang.String s,
int n,
char pad)
Returns the blank-delimited words in the receiving string, with n pad characters between each word. |
static java.lang.String |
strip(java.lang.String cadena)
Opci� per defecte de strip. |
static java.lang.String |
strip(java.lang.String cadena,
char charEsborrat)
Opci� per defecte de strip quan no s'especifica d'on es treuen els car�cters. |
static java.lang.String |
strip(java.lang.String cadena,
java.lang.String deOn)
Opci� per defecte de strip quan no s'especifica el car�cter que s'elimina. |
static java.lang.String |
strip(java.lang.String cadena,
java.lang.String deOn,
char charEsborrat)
Port de la funci� strip de REXX. |
static java.lang.String |
subStr(java.lang.String s,
int start)
Returns the substring of the receiving string that begins at the nth character. |
static java.lang.String |
subStr(java.lang.String s,
int start,
int len)
Returns the sub-string of String s that begins at the start character, and is of length len [padded with blank characters if necessary]. |
static java.lang.String |
subStr(java.lang.String s,
int start,
int len,
char pad)
Returns the sub-string of String s that begins at the
start character, and is of length len [padded
with pad characters if necessary]. |
static java.lang.String |
subWord(java.lang.String s,
int firstWordNum)
Returns the substring of string that starts at the nth word, and is up to remaining blank-delimited words. |
static java.lang.String |
subWord(java.lang.String s,
int firstWordNum,
int numWords)
Returns the substring of string that starts at the nth word, and is up to length blank-delimited words. |
static java.lang.String |
translate(java.lang.String s)
Returns s with each character translated to another character or unchanged. |
static java.lang.String |
translate(java.lang.String s,
char pad)
Returns s with each character translated to another character or unchanged. |
static java.lang.String |
translate(java.lang.String s,
java.lang.String tableo)
Returns s with each character translated to another character or unchanged. |
static java.lang.String |
translate(java.lang.String s,
java.lang.String tableo,
java.lang.String tablei)
Returns s with each character translated to another character or unchanged. |
static java.lang.String |
translate(java.lang.String s,
java.lang.String tableo,
java.lang.String tablei,
char pad)
Returns s with each character translated to another character or unchanged. |
static java.lang.String |
UAcc(java.lang.String s)
|
static java.lang.String |
word(java.lang.String s,
int n)
Returns the nth blank-delimited word in string or returns the null string if fewer than n words are in string. |
static int |
wordIndex(java.lang.String s,
int n)
Returns the position of the first character in the nth blank-delimited word in s or returns -1 if fewer than n words are in s or s is null or s haves length 0. |
static int |
wordLength(java.lang.String s,
int n)
Returns the length of the nth blank-delimited word in string s or returns 0 if fewer than n words are in string s. |
static int |
words(java.lang.String s)
Returns the number of blank-delimited words in string. |
static java.lang.String |
xrange()
Returns a string of all valid 1-byte encodings (in ascending order) between and including the values start (0x00) and end (0xFF). |
static java.lang.String |
xrange(char start)
Returns a string of all valid 1-byte encodings (in ascending order) between and including the values start and 0xFF. start must be a single character. |
static java.lang.String |
xrange(char start,
char end)
Returns a string of all valid 1-byte encodings (in ascending order) between and including the values start and end. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Strings()
Method Detail |
---|
public static java.lang.String center(java.lang.String s, int len)
len
with s
centered in it, with pad characters added as necessary to make up
len
. Creation date: (18/8/99 10:36:04)
s
- The String
to be centered.len
- int The length of final String
String
with s
centered in it.StringTools#center(String, int, char)
public static java.lang.String center(java.lang.String s, int len, char pad)
len
with s
centered in it, with pad characters added as necessary to make up
len
. The len must be a positive whole number or zero. The
default pad character is blank. If the string s
is longer
than len
, it is truncated at both ends to fit. If an odd
number of characters are truncated or added, the right-hand end loses or
gains one more character than the left-hand end.
Here are some examples:
center("abc",7) // " ABC "
center("abc",8,'-') // "--ABC---"
center("The blue sky",8) // "e blue s"
center("The blue sky",7) // "e blue "
centre
or center
. Creation date: (18/8/99 10:34:05)
s
- The String
to be centered.len
- int The length of final String
pad
- The padding character
String
with s
centered in it.
public static java.lang.String centre(java.lang.String s, int len)
s
- The String
to be centered.len
- int The length of final String
String
with s
centered in it.StringTools#center(String, int, char)
public static java.lang.String centre(java.lang.String s, int len, char pad)
s
- The String
to be centered.len
- int The length of final String
pad
- The padding character
String
with s
centered in it.StringTools#center(String, int, char)
public static java.lang.String changeStr(java.lang.String needle, java.lang.String haystack, java.lang.String newneedle)
needle
in haystack
with newneedle
.
Examples:
'
StringTools.changeStr("1","101100","") - '000'
Creation date: (19/8/99 9:13:49)
StringTools.changeStr("1","101100","X") - 'X0XX00
needle
- Substring to be replacedhaystack
- String to be changednewneedle
- Substring to replace needle
String
with the occurrences of
needle
replacedpublic static int compare(java.lang.String s1, java.lang.String s2)
s1
- First element of compares2
- Second element of compare
StringTools#compare(String, String, char)
public static int compare(java.lang.String s1, java.lang.String s2, char pad)
COMPARE('abc','abc') - -1
COMPARE('abc','ak') - 1
COMPARE('ab ','ab') - -1
COMPARE('ab ','ab',' ') - -1
COMPARE('ab ','ab','x') - 2
COMPARE('ab-- ','ab','-') - 4
Creation date: (19/8/99 12:25:00)
s1
- First element of compares2
- Second element of comparepad
- Padding for the shorter string
public static java.lang.String copies(char c, int times)
times
concatenated copies of c
.Here are some examples:
copies('a',3) - "aaa"
copies('a',0) - ""
Creation date:
(18/8/99 10:28:56)
Modified: (11/6/99 09:01:23): if (times == 0) return null
becomes [...] return ""
like in Rexx.
c
- chartimes
- int
public static java.lang.String copies(java.lang.String s, int times)
times
concatenated copies of c
.Here are some examples:
copies("123",3) - "123123123"
copies("123",0) - ""
Creation
date: (18/8/99 10:30:40)
Modified: (11/6/99 09:02:15): Added if (times == 0) return ""
to do the same as in copies(char, int)
.
s
- java.lang.Stringtimes
- int
public static int countStr(java.lang.String needle, java.lang.String haystack)
Here are several examples:
countStr("1", "101101")) - 4
countStr("KK", "J0KKK0") - 1
Creation date: (19/8/99 11:57:31)
needle
- java.lang.Stringhaystack
- java.lang.String
public static boolean dataType(java.lang.String value, char type)
value
- => the string we are checking the type.type
- => the type we are checking the string complies.
public static java.lang.String delStr(java.lang.String s, int start)
s
- java.lang.Stringstart
- int
public static java.lang.String delStr(java.lang.String s, int start, int len)
Here are some examples:
delStr("abcd",2) - "ab"
delStr("abcde",2,2) - "abe"
delStr("abcde",5) - "abcde"
Creation date: (19/8/99 13:36:13)
s
- java.lang.Stringstart
- intlen
- int
public static java.lang.String delWord(java.lang.String s, int start)
s
- java.lang.Stringstart
- int
public static java.lang.String delWord(java.lang.String s, int start, int len)
Here are some examples:
delWord("Now is the time",2,2) - 'Now time'
delWord("Now is the time ",3) - 'Now is '
delWord("Now is the time",5) - 'Now is the time'
delWord("Now is the time",3,1) - 'Now is time'
Creation date: (20/8/99 13:28:50)
s
- java.lang.Stringstart
- intlen
- int
public static java.lang.String insert(java.lang.String snew, java.lang.String target)
Here are some examples:
insert(" ","abcdef",3) - 'abc def'
insert("123","abc",5,6) - 'abc 123 '
insert("123","abc",5,6,'+') - 'abc++123+++'
insert("123","abc") - '123abc'
insert("123","abc",,5,'-') - '123--abc'
Creation date: (20/8/99 14:09:02)
snew
- java.lang.Stringtarget
- java.lang.String
StringTools#insert(String, String, int, int, char)
public static java.lang.String insert(java.lang.String snew, java.lang.String target, int n)
Here are some examples:
insert(" ","abcdef",3) - 'abc def'
insert("123","abc",5,6) - 'abc 123 '
insert("123","abc",5,6,'+') - 'abc++123+++'
insert("123","abc") - '123abc'
insert("123","abc",,5,'-') - '123--abc'
Creation date: (20/8/99 14:11:26)
snew
- java.lang.Stringtarget
- java.lang.Stringn
- int
StringTools#insert(String, String, int, int, char)
public static java.lang.String insert(java.lang.String snew, java.lang.String target, int n, int len)
Here are some examples:
insert(" ","abcdef",3) - 'abc def'
insert("123","abc",5,6) - 'abc 123 '
insert("123","abc",5,6,'+') - 'abc++123+++'
insert("123","abc") - '123abc'
insert("123","abc",,5,'-') - '123--abc'
Creation date: (20/8/99 14:13:10)
snew
- java.lang.Stringtarget
- java.lang.Stringn
- intlen
- int
StringTools#insert(String, String, int, int, char)
public static java.lang.String insert(java.lang.String snew, java.lang.String target, int n, int len, char pad)
Here are some examples:
insert(" ","abcdef",3) - 'abc def'
insert("123","abc",5,6) - 'abc 123 '
insert("123","abc",5,6,'+') - 'abc++123+++'
insert("123","abc") - '123abc'
insert("123","abc",,5,'-') - '123--abc'
Creation date: (20/8/99 14:02:11)
snew
- java.lang.Stringtarget
- java.lang.Stringn
- intlen
- intpad
- char
public static int lastPos(char needle, java.lang.String haystack)
lastIndex
method of String
class.
Creation date: (23/8/99 13:51:14)
needle
- java.lang.Stringhaystack
- java.lang.String
StringTools#lastPos(char, String, int)
public static int lastPos(char needle, java.lang.String haystack, int start)
lastIndex
method of String
class.
I include this method for Rexx compatibility.
Here are some examples:
lastPos(' ',"abc def ghi") - 7
lastPos(' ',"abcdefghi") - -1
lastPos('xy',"efgxyz") - 3
lastPos(' ',"abc def ghi",6) - 3
Creation date: (23/8/99 13:51:14)
needle
- charhaystack
- java.lang.Stringstart
- int
public static int lastPos(java.lang.String needle, java.lang.String haystack)
lastIndex
method of String
class.
I include this method for Rexx compatibility.
Here are some examples:
lastPos(" ","abc def ghi") - 7
lastPos(" ","abcdefghi") - -1
lastPos("xy","efgxyz") - 3
lastPos(" ","abc def ghi",6) - 3
Creation date: (23/8/99 13:51:14)
needle
- charhaystack
- java.lang.String
StringTools#lastPos(String, String, int)
public static int lastPos(java.lang.String needle, java.lang.String haystack, int start)
lastIndex
method of String
class.
I include this method for Rexx compatibility.
Here are some examples:
lastPos(" ","abc def ghi") - 7
lastPos(" ","abcdefghi") - -1
lastPos("xy","efgxyz") - 3
lastPos(" ","abc def ghi",6) - 3
Creation date: (23/8/99 13:51:14)
needle
- java.lang.Stringhaystack
- java.lang.Stringstart
- int
public static java.lang.String left(java.lang.String s, int len)
Creation date: (18/8/99 10:20:49)
s
- java.lang.Stringlen
- int
StringTools#left(String, int, char)
public static java.lang.String left(java.lang.String s, int len, char pad)
left("1234", 2) - "12"
left("1234", 6) - "1234 "
left("1234", 6, '+') - "1234++"
Creation date: (18/8/99 10:19:58)
s
- java.lang.Stringlen
- intpad
- char
public static java.lang.String overlay(java.lang.String snew, java.lang.String target)
snew
- java.lang.Stringtarget
- java.lang.String
StringTools#overlay(String, String, int, int, char)
public static java.lang.String overlay(java.lang.String snew, java.lang.String target, int n)
snew
- java.lang.Stringtarget
- java.lang.Stringn
- int
StringTools#overlay(String, String, int, int, char)
public static java.lang.String overlay(java.lang.String snew, java.lang.String target, int n, int len)
snew
- java.lang.Stringtarget
- java.lang.Stringn
- intlen
- int
public static java.lang.String overlay(java.lang.String snew, java.lang.String target, int n, int len, char pad)
Here are some examples:
overlay(" ","abcdef",2); // 'ab def'
overlay(".","abcdef",2,2); // 'ab. ef'
overlay("qq","abcd"); // 'qqcd'
overlay("qq","abcd",3); // 'abcqq'
overlay("123","abc",4,6,'+'); // 'abc+123+++'
Creation date: (23/8/99 14:11:57)
snew
- java.lang.Stringtarget
- java.lang.Stringn
- intlen
- intpad
- char
public static int pos(char needle, java.lang.String haystack)
index
method of String
class.
Creation date: (19/05/2005 16:08:14)
needle
- java.lang.Stringhaystack
- java.lang.String
public static int pos(char needle, java.lang.String haystack, int start)
lastIndex
method of String
class.
I include this method for Rexx compatibility.
Here are some examples:
pos(' ',"abc def ghi") - 3
pos(' ',"abcdefghi") - -1
pos('x',"efgxyz") - 3
Creation date: (19/05/2005 16:08:14)
needle
- charhaystack
- java.lang.Stringstart
- int
public static int pos(java.lang.String needle, java.lang.String haystack)
lastIndex
method of String
class.
I include this method for Rexx compatibility.
Here are some examples:
pos(" ","abc def ghi") - 3
pos(" ","abcdefghi") - -1
pos("xy","efgxyz") - 3
Creation date: (19/05/2005 16:06:14)
needle
- charhaystack
- java.lang.String
StringTools#lastPos(String, String, int)
public static int pos(java.lang.String needle, java.lang.String haystack, int start)
indexOf
method of String
class.
I include this method for Rexx compatibility.
Here are some examples:
pos(" ","abc def ghi") - 3
pos(" ","abcdefghi") - -1
pos("xy","efgxyz") - 3
pos(" ","abc def ghi",5) - 7
Creation date: (19/05/2005 16:04:14)
needle
- java.lang.Stringhaystack
- java.lang.Stringstart
- int
public static java.lang.String reverse(java.lang.String s)
reverse("cBA") - "ABc"
reverse("XYZ ") - " ZYX"
Creation date: (24/8/99 11:10:00)
s
- java.lang.String
public static java.lang.String right(java.lang.String s, int len)
s
- java.lang.Stringlen
- int
StringTools#right(String, int, char)
public static java.lang.String right(java.lang.String s, int len, char pad)
Here are some examples:
right("abc d",8) // ' abc d'
right("abc def",5) // 'c def'
right("12",5,'0') // '00012'
Creation date: (18/8/99 10:26:21)
Modified: (11/6/99 08:56:43): Added
if (len = s.length()) return s
.
s
- java.lang.Stringlen
- intpad
- char
public static java.lang.String space(java.lang.String s)
s
- java.lang.String
StringTools#space(String, int, char)
public static java.lang.String space(java.lang.String s, char pad)
s
- java.lang.Stringpad
- char
StringTools#space(String, int, char)
public static java.lang.String space(java.lang.String s, int n)
s
- java.lang.Stringn
- int
StringTools#space(String, int, char)
public static java.lang.String space(java.lang.String s, int n, char pad)
n
pad
characters between each word. If you
specify n, it must be a positive whole number or zero. If it is 0, all
blanks are removed. Leading and trailing blanks are always removed. The
default for n is 1, and the default pad character is a blank. Creation
date: (24/8/99 13:55:44)
s
- java.lang.Stringn
- intpad
- char
public static java.lang.String strip(java.lang.String cadena)
cadena
-
public static java.lang.String strip(java.lang.String cadena, char charEsborrat)
cadena
-
public static java.lang.String strip(java.lang.String cadena, java.lang.String deOn)
cadena
-
public static java.lang.String strip(java.lang.String cadena, java.lang.String deOn, char charEsborrat)
cadena
- deOn
- charEsborrat
-
public static java.lang.String subStr(java.lang.String s, int start)
s
- java.lang.Stringstart
- int
StringTools#subStr(String, int, int, char)
public static java.lang.String subStr(java.lang.String s, int start, int len)
s
- java.lang.Stringstart
- intlen
- int
StringTools#subStr(String, int, int, char)
public static java.lang.String subStr(java.lang.String s, int start, int len, char pad)
s
that begins at the
start
character, and is of length len
[padded
with pad
characters if necessary]. start
must
be a positive whole number and len
must be a non-negative
whole number. If start
is greater than
s.length()
, then only pad characters can be returned.
If len
is omitted it defaults to be the rest of the string.
The default pad character is a blank.
Here are some examples:
subStr("abc", 1) // "bc" subStr("abc", 1, 4) // "bc " subStr("abc", 4, 4) // " " subStr("abc", 1, 6, '.') // "bc...." subStr("abc", 4, 6, '.') // "......"Creation date: (31/3/00 18:58:28)
s
- java.lang.Stringstart
- intlen
- intpad
- char
public static java.lang.String subWord(java.lang.String s, int firstWordNum)
s
- java.lang.StringfirstWordNum
- int
StringTools#subWord(String, int, int)
public static java.lang.String subWord(java.lang.String s, int firstWordNum, int numWords)
Here are some examples:
subWord("Now is the time",2,2); // "is the"
subWord("Now is the time",3); // "the time"
subWord("Now is the time",5); // ""
Creation date: (19/8/99 9:07:30)
s
- java.lang.StringfirstWordNum
- intnumWords
- int Lenght in words.
public static java.lang.String translate(java.lang.String s)
The output table is tableo and the input translation table is tablei. TRANSLATE searches tablei for each character in s. If the character is found, then the corresponding character in tableo is used in the result string; if there are duplicates in tablei, the first (leftmost) occurrence is used. If the character is not found, the original character in s is used. The result string is always the same length as string s.
The tables can be of any length. If you specify neither translation table and omit pad, string is simply translated to uppercase (that is, lowercase a-z to uppercase A-Z), but, if you include pad, the language processor translates the entire string to pad characters. tablei defaults (when null) to xrange(0x00, 0xFF), and tableo defaults to the null string and is padded with pad or truncated as necessary. The default pad is a blank.
Here are some examples:
translate("abcdef"); // 'ABCDEF'
translate("abcdef", '+'); // '++++++'
translate("abcdef","12","ec"); // 'ab2d1f'
translate("abcdef","12","abcd",'.'); // '12..ef'
translate("APQRV",null,"PR"); // 'A Q V'
translate("4123","abcd","1234"); // 'dabc'
translate("APQRV",xrange((char)0x0,'Q')); // 'APQ '
s
- java.lang.String
StringTools#translate(String, String, String, char)
public static java.lang.String translate(java.lang.String s, char pad)
The output table is tableo and the input translation table is tablei. TRANSLATE searches tablei for each character in s. If the character is found, then the corresponding character in tableo is used in the result string; if there are duplicates in tablei, the first (leftmost) occurrence is used. If the character is not found, the original character in s is used. The result string is always the same length as string s.
The tables can be of any length. If you specify neither translation table and omit pad, string is simply translated to uppercase (that is, lowercase a-z to uppercase A-Z), but, if you include pad, the language processor translates the entire string to pad characters. tablei defaults (when null) to xrange(0x00, 0xFF), and tableo defaults to the null string and is padded with pad or truncated as necessary. The default pad is a blank.
Here are some examples:
translate("abcdef"); // 'ABCDEF'
translate("abcdef", '+'); // '++++++'
translate("abcdef","12","ec"); // 'ab2d1f'
translate("abcdef","12","abcd",'.'); // '12..ef'
translate("APQRV",null,"PR"); // 'A Q V'
translate("4123","abcd","1234"); // 'dabc'
translate("APQRV",xrange((char)0x0,'Q')); // 'APQ '
s
- java.lang.Stringpad
- char
StringTools#translate(String, String, String, char)
public static java.lang.String translate(java.lang.String s, java.lang.String tableo)
The output table is tableo and the input translation table is tablei. TRANSLATE searches tablei for each character in s. If the character is found, then the corresponding character in tableo is used in the result string; if there are duplicates in tablei, the first (leftmost) occurrence is used. If the character is not found, the original character in s is used. The result string is always the same length as string s.
The tables can be of any length. If you specify neither translation table and omit pad, string is simply translated to uppercase (that is, lowercase a-z to uppercase A-Z), but, if you include pad, the language processor translates the entire string to pad characters. tablei defaults (when null) to xrange(0x00, 0xFF), and tableo defaults to the null string and is padded with pad or truncated as necessary. The default pad is a blank.
Here are some examples:
translate("abcdef"); // 'ABCDEF'
translate("abcdef", '+'); // '++++++'
translate("abcdef","12","ec"); // 'ab2d1f'
translate("abcdef","12","abcd",'.'); // '12..ef'
translate("APQRV",null,"PR"); // 'A Q V'
translate("4123","abcd","1234"); // 'dabc'
translate("APQRV",xrange((char)0x0,'Q')); // 'APQ '
s
- java.lang.Stringtableo
- java.lang.String
StringTools#translate(String, String, String, char)
public static java.lang.String translate(java.lang.String s, java.lang.String tableo, java.lang.String tablei)
The output table is tableo and the input translation table is tablei. TRANSLATE searches tablei for each character in s. If the character is found, then the corresponding character in tableo is used in the result string; if there are duplicates in tablei, the first (leftmost) occurrence is used. If the character is not found, the original character in s is used. The result string is always the same length as string s.
The tables can be of any length. If you specify neither translation table and omit pad, string is simply translated to uppercase (that is, lowercase a-z to uppercase A-Z), but, if you include pad, the language processor translates the entire string to pad characters. tablei defaults (when null) to xrange(0x00, 0xFF), and tableo defaults to the null string and is padded with pad or truncated as necessary. The default pad is a blank.
Here are some examples:
translate("abcdef"); // 'ABCDEF'
translate("abcdef", '+'); // '++++++'
translate("abcdef","12","ec"); // 'ab2d1f'
translate("abcdef","12","abcd",'.'); // '12..ef'
translate("APQRV",null,"PR"); // 'A Q V'
translate("4123","abcd","1234"); // 'dabc'
translate("APQRV",xrange((char)0x0,'Q')); // 'APQ '
s
- java.lang.Stringtableo
- java.lang.Stringtablei
- java.lang.String
StringTools#translate(String, String, String, char)
public static java.lang.String translate(java.lang.String s, java.lang.String tableo, java.lang.String tablei, char pad)
The output table is tableo and the input translation table is tablei. TRANSLATE searches tablei for each character in s. If the character is found, then the corresponding character in tableo is used in the result string; if there are duplicates in tablei, the first (leftmost) occurrence is used. If the character is not found, the original character in s is used. The result string is always the same length as string s.
The tables can be of any length. If you specify neither translation table and omit pad, string is simply translated to uppercase (that is, lowercase a-z to uppercase A-Z), but, if you include pad, the language processor translates the entire string to pad characters. tablei defaults (when null) to xrange(0x00, 0xFF), and tableo defaults to the null string and is padded with pad or truncated as necessary. The default pad is a blank.
Here are some examples:
translate("abcdef"); // 'ABCDEF'
translate("abcdef", '+'); // '++++++'
translate("abcdef","12","ec"); // 'ab2d1f'
translate("abcdef","12","abcd",'.'); // '12..ef'
translate("APQRV",null,"PR"); // 'A Q V'
translate("4123","abcd","1234"); // 'dabc'
translate("APQRV",xrange((char)0x0,'Q')); // 'APQ '
s
- java.lang.Stringtableo
- java.lang.Stringtablei
- java.lang.Stringpad
- char
public static java.lang.String UAcc(java.lang.String s)
public static java.lang.String word(java.lang.String s, int n)
subWord(string,n,1)
.
Here are some examples:
word("Now is the time",3); // 'the'
word("Now is the time",5); // ''
Creation date: (19/8/99 9:03:25)
s
- java.lang.Stringn
- int Word number
public static int wordIndex(java.lang.String s, int n)
Here are some examples:
wordIndex("Now is the time",3); // 7
wordIndex("Now is the time",6); // -1
Creation date: (25/8/99 13:15:33)
s
- java.lang.Stringn
- int
public static int wordLength(java.lang.String s, int n)
Here are some examples:
wordLength("Now is the time",2); // 2
wordLength("Now comes the time",2); // 5
wordLength("Now is the time",6); // 0
Creation date: (25/8/99 13:28:28)
s
- java.lang.Stringn
- int
public static int words(java.lang.String s)
Here are some examples:
words("Now is the time"); // 4
words(" "); // 0
In NetRexx the tab character is not a word delimiter. Only the blank character is a word delimited.
Creation date: (18/8/99 11:10:17)
s
- java.lang.String
public static java.lang.String xrange()
Here are some examples:
xrange(); // [0x00 .. 0xFF]
Creation date: (25/8/99 12:33:12)
public static java.lang.String xrange(char start)
Here are some examples:
xrange('a'); // [a .. 0xFF]
Creation date: (25/8/99 12:32:11)
start
- char
public static java.lang.String xrange(char start, char end)
Here are some examples:
xrange('a','f') - 'abcdef'
xrange('i','j') - 'ij'
Creation date: (25/8/99 12:22:15)
start
- charend
- char
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |