Hi,
CAUTION; I am not a programmer of any type but I have scraped together some function ideas and I am after some assistance in making sure they are workable before I try them out. I am also after any advice on whether they are good or bad ideas.
- Remove a specified Character from end of a string. In this case I am imagining doing something like RemoveCharacterAtEnd(title,"."). This would remove all instances of that character from the end of the field nominated.
\t while (value.endsWith(character)
\t\t{
\tvalue = value.substring(0, value.length() - 1);
\t}
\t\tvalue = value.trim()
\treturn value;
}
- Remove a specified Character from start of a string. In this case I am imagining doing something like RemoveCharacterAtFront(title,"."). This would remove all instances of that character from the front of the field nominated.
function RemoveCharacterAtFront(value,character) {
\t while (value.startsWith(character)
\t\t{
\tvalue = value.substring(1, value.length() - 1);
\t}
\t\tvalue = value.trim()
\treturn value;
}
- Removing all forms of punctuation from the end of a string. In this case using it like RemovePunctuationAtEnd(title). This will only allow it to end in a character a-z (upper and lower case) or a number.
unction RemovePunctuationAtEnd(value) {
\t\tvalue = value.replaceAll("[^a-zA-Z0-9]+$", "")
\t\treturn value;
\t
}
- Removing all forms of punctuation from the start of a string. In this case using it like RemovePunctuationAtStart(title). This will only allow it to start in a character a-z (upper and lower case) or a number.
function RemovePunctuationAtStart(value) {
\t\tvalue = value.replaceFirst("^[^a-zA-Z0-9]+", "")
\t\treturn value;
}
- This one I am not sure about at all. I am trying to use a regex expression I found that finds strings that begin with “The” and it will then move it to the end of the string after a comma - “, The”. This was an utter guess .
function suffixThe(value) {
\tvalue = value.replaceAll(find /^(?i)(The)\\s(.*)$/ replace with "$2, $1")
\treturn value;
\t}
Laughter at my attempt is allowed.
:oops:
Laurie