In VB6 what is the difference between Property Set and Property Let?
Property Set is for objects (e.g., class instances) Property Let is for “normal” datatypes (e.g., string, boolean, long, etc.)
Property Set is for objects (e.g., class instances) Property Let is for “normal” datatypes (e.g., string, boolean, long, etc.)
+1 for word boundaries, and here is a comparable Javascript solution. This accounts for possessives, as well: var re = /(\b[a-z](?!\s))/g; var s = “fort collins, croton-on-hudson, harper’s ferry, coeur d’alene, o’fallon”; s = s.replace(re, function(x){return x.toUpperCase();}); console.log(s); // “Fort Collins, Croton-On-Hudson, Harper’s Ferry, Coeur D’Alene, O’Fallon”
To check if a character is lower case, use the islower method of str. This simple imperative program prints all the lowercase letters in your string: for c in s: if c.islower(): print c Note that in Python 3 you should use print(c) instead of print c. Possibly ending up with assigning those letters to … Read more
Like many problems to do with strings, this can be done in a simple way with a regex. >>> word = ‘Llanfairpwllgwyn|gyllgogerychwyrndrobwllllantysiliogogogoch’ >>> import re >>> pattern = re.compile(r’ch|dd|ff|ng|ll|ph|rh|th|[^\W\d_]’, flags=re.IGNORECASE) >>> len(pattern.findall(word)) 51 The character class [^\W\d_] (from here) matches word-characters that are not digits or underscores, i.e. letters, including those with diacritics.
I don’t believe there is a built-in function for that. But it’s easy enough to write with a regex function isLetter(str) { return str.length === 1 && str.match(/[a-z]/i); }
Character.isDigit(string.charAt(index)) (JavaDoc) will return true if it’s a digit Character.isLetter(string.charAt(index)) (JavaDoc) will return true if it’s a letter
Since dart version 2.6, dart supports extensions: extension StringExtension on String { String capitalize() { return “${this[0].toUpperCase()}${this.substring(1).toLowerCase()}”; } } So you can just call your extension like this: import “string_extension.dart”; var someCapitalizedString = “someString”.capitalize();
Only because no one else has mentioned it: >>> ‘bob’.title() ‘Bob’ >>> ‘sandy’.title() ‘Sandy’ >>> ‘1bob’.title() ‘1Bob’ >>> ‘1sandy’.title() ‘1Sandy’ However, this would also give >>> ‘1bob sandy’.title() ‘1Bob Sandy’ >>> ‘1JoeBob’.title() ‘1Joebob’ i.e. it doesn’t just capitalize the first alphabetic character. But then .capitalize() has the same issue, at least in that ‘joe Bob’.capitalize() … Read more