codethesaur.us
codethesaur.us copied to clipboard
Add RexEx functions to meta strings file
Please ONLY take this issue if you have experience working with a wide variety of programming languages (aka, are a polyglot).
The strings.json
meta language file didn't include how to match patterns from RegExs. This issue is to add those in here.
- This should probably be its own category (like "Find and Search" and "Manipulating Strings" are)
- This should include all functions that can use RegEx. (this shouldn't include how to use RegExes themselves. That's a tutorial for someone to review on another site.)
- Try to think across many languages and how many implement this sort of thing
- Make sure the order you define the category and concept ID on the top part match where you put the concept ID on the bottom half of the file.
Feel free to add any discussions below and we (you and I, Sarah) can talk them out.
original inspiration issue comment below
@geekygirlsarah Started this and found that there are somethings that are possible but via other methods:
is_all_alphanumeric - Can be done using Regex
is_all_alphabetical - Can be done using Regex but also can be done at a char level so could loop over the string as well
is_all_uppercase, is_all_lowercase - Can be done at a char level ^^
remove_whitespace - Can't remove all whitespace but string.Trim()
will remove leading and trailing whitespace.
replace_substring - For a single replacement Regex.IsMatch(pattern, numberToMatch);
can be used
format_as_integer - What is actually meant by this?
format_number_in_binary, format_number_in_octal - Can be done using Convert.ToString(int num, int base);
but would need to convert to and integer first and there is no formatter for it.
Further to this due to how C# manages strings clear_string doesn't actually make much sense as s1 = string.Empty;
will actually just create a new string so it doesn't clear the string but instead changes the pointer reference. Unless this means how to create and empty string?
Originally posted by @blockingHD in https://github.com/codethesaurus/codethesaur.us/issues/365#issuecomment-943766699