Returns a extString.
Extensions to String
| pitchClassNameRegexBody | |
| pitchNameRegexBody |
| capitalizeFirst | |
| delimit | |
| delimitByWhiteSpace | |
| delimitWords | |
| ditto | |
| formatttt | Returns a string. |
| formatColumn | |
| partition | |
| indent | Prepend each non-blank line with whitespace. |
| dedent | Remove the length of whitespace found at the start of the first line from all lines. |
| removeLeadingWhiteSpace | Removes any whitespace between a newline and the first alphanumeric character, including tabs. |
| removeTabs | Strips amy whitespace that appear after newline and before alphanumeric characters. |
| removeWhiteSpace | !!! rename: stripWhiteSpace |
| splitLines | Identical to splitlines in python. |
| strip | Similar to strip in python. |
| title | Capitalise the first letter of each word in string. Same as title in python. |
| toDashCase | |
| toLowerDashCase | |
| toLowerCamelCase | |
| toLowerSnakeCase | |
| toUpperCamelCase | |
| toUpperDashCase | |
| toUpperSnakeCase |
Example
x ="Bb4 A#2 C3 Dbb1 A+7 A#+2 G~1 Gb~-3";
m = x.findRegexp("".pitchClassNameRegexBody).flop[1];[ "Bb", "b", "A#", "#", "C", "", "Dbb", "bb", "A+", "+", "A#+", "#+", "G~", "~", "Gb~", "b~" ]Example
x ="Bb4 A#2 C3 Dbb1 A+7 A#+2 G~1 Gb~-3";
m = x.findRegexp("".pitchNameRegexBody).flop[1];[ "Bb4", "b", "4", "A#2", "#", "2", "C3", "", "3", "Dbb1", "bb", "1", "A+7", "+", "7", "A#+2", "#+", "2", "G~1", "~", "1", "Gb~-3", "b~", "-3" ]Example
x ="Bb4 A#2 <C3 Dbb1 A+7> A#+2 G~1 Gb~-3";
m = x.findRegexp("<.*>").flop[1];[ "<C3 Dbb1 A+7>" ]Example
"scale degrees 4 and 5.".capitalizeFirst;Scale degrees 4 and 5.Example
x = "asd\nasdsad\nasdd";
x.delimitBy("\\n");[ "asd", "asdsad", "asdd" ]Example
"C#4 Ab Bb4 D5".delimitByWhiteSpace;[ "C#4", "Ab", "Bb4", "D5" ]Example
"scale degrees 4 and 5.".delimitWords;[ "scale", "degrees", "4", "and", "5" ]
"scale degrees 4and5.".delimitWords;[ "scale", "degrees", "4", "and", "5" ]
"scaleDegrees4and5.".delimitWords;[ "scale", "Degrees", "4", "and", "5" ]
"ScaleDegrees4and 5.".delimitWords;[ "Scale", "Degrees", "4", "and", "5" ]
"scale-degrees-4-and-5.".delimitWords;[ "scale", "degrees", "4", "and", "5" ]
"SCALE_DEGREES_4_AND_5.".delimitWords;[ "SCALE", "DEGREES", "4", "AND", "5" ]
"one < two".delimitWords;[ "one", "<", "two" ]
"one! two!".delimitWords;[ "one", "!", "two", "!" ]Example
"blah".ditto;blahblah
"blah".ditto(3);blahblahblahReturns a string.
Example
x = Array.geom(20, 1000, 7/10);
x.collect { |n| n.format(precision: 3, width: 8) }.join("\n");1000.000
700.000
489.000
342.000
240.100
168.070
117.649
82.354
57.648
40.354
28.248
19.773
13.841
9.689
6.782
4.748
3.323
2.326
1.628
1.140Example
"".formatRow([1,2,3], 6, precision: 2);0.00 0.00 0.00Prepend each non-blank line with whitespace.
Example
a = "1\n2\n\n4\n5";
a.indent.cs;" 1
2
4
5"
a.indent(8).cs;" 1
2
4
5"Remove the length of whitespace found at the start of the first line from all lines.
WARNING/FIXME: will kill non-whitespace from subsequent lines with less leading whitespace!
Example
a = " some text\n with differently indented\n lines.";
a.dedent.cs;"some text
with differently indented
lines."Removes any whitespace between a newline and the first alphanumeric character, including tabs.
Example
a = "Gets forbidden note duration.\n\n Returns duration or nil.";
b = a.removeLeadingWhiteSpace;Gets forbidden note duration.
Returns duration or nil.Strips amy whitespace that appear after newline and before alphanumeric characters.
Example
a = "Gets forbidden note duration.\n\n\tReturns duration or nil.";
a.removeTabs;Gets forbidden note duration.
Returns duration or nil.!!! rename: stripWhiteSpace
Example
"scale degrees 4 and 5.".removeWhiteSpace;scaledegrees4and5.Identical to splitlines in python.
Example
"\none\ntwo\nthree".splitLines;
"one\ntwo\nthree".splitLines;[ "one", "two", "three" ]Similar to strip in python.
Example
"__one_two__three___".strip($_);
"__one_two__three___".strip("_");
" one two three ".strip;one two threeCapitalise the first letter of each word in string. Same as title in python.
Example
"one two three-and-four".title;One Two Three And FourExample
"scaleDegrees4and5.".toDashCase;
"SCALE_DEGREES_4_AND_5.".toDashCase;
"SCALE DEGREES 4 AND 5.".toDashCase;SCALE-DEGREES-4-AND-5Example
"scaleDegrees4and5.".toLowerDashCase;
"SCALE_DEGREES_4_AND_5.".toLowerDashCase;scale-degrees-4-and-5Example
"scale-degrees-4-and-5.".toLowerCamelCase;
"SCALE_DEGREES_4_AND_5.".toLowerCamelCase;scaleDegrees4And5Example
"scaleDegrees4and5.".toLowerSnakeCase;
"SCALE_DEGREES_4_AND_5.".toLowerSnakeCase;scale_degrees_4_and_5Example
"scale-degrees-4-and-5.".toUpperCamelCase;
"SCALE_DEGREES_4_AND_5.".toUpperCamelCase;ScaleDegrees4And5Example
"scale-degrees-4-and-5.".toUpperDashCase;
"SCALE_DEGREES_4_AND_5.".toUpperDashCase;Scale-Degrees-4-And-5Example
"scale-degrees-4-and-5.".toUpperSnakeCase;
"SCALE_DEGREES_4_AND_5.".toUpperSnakeCase;Scale_Degrees_4_And_5