Noted Josiah!
I will add these modification!
I hope you have time to add more explanation both solutions have been given!
On Friday, August 23, 2019 at 10:46:21 PM UTC+4:30, @TiddlyTweeter wrote:
>
> Ciao Mark & Mohammad a few tweaks for Mark's solutions ...
>
> * (I'm happy to be aiding Mark, as it's usually the other way round,
> lol :-)!*
>
> <option value="^[0-9]*$">Only digits</option>
>> <option value="^[a-z]*$">Only lower case</option>
>> <option value="^[A-Z]*$">Only upper case</option>
>
>
> These will work, but would also match "the empty string".
> Probably better to use "+" (one or more), not "*" (zero or more), so ...
>
> <option value="^[0-9]+$">Only digits</option>
> or use "\d", shorthand for [0-9]
> <option value="^\d+$">Only digits</option> "\d" is shorthand for [0-9]
>
> <option value="^[a-z]+$">Only lower case</option>
> <option value="^[A-Z]+$">Only upper case</option>
>
> <option value="^[\w-_]*$">Only alphanumeric, _, and -</option>
>
>
> Its not ideal to put "\w" inside a character class as it is a shorthand
> character class for [A-Za-z0-9_].
>
> "\w" already includes "_" so you don't need to add it.
>
> Its not ideal to put "-" in the middle of a character class as it can
> sometimes act as a "range marker"
>
> Any of these should work ...
>
> <option value="^(\w|-)+$">Only alphanumeric, _, and -</option>
> or
> <option value="^[-a-zA-Z0-9_]+$">Only alphanumeric, _, and -</option>
> or, its good practice to make explicit the need for literal "-", like so
> ...
> <option value="^[\-a-zA-Z0-9_]+$">Only alphanumeric, _, and -</option>
> or, less kosher
> <option value="^[\-\w]+$">Only alphanumeric, _, and -</option>
>
> <option value="^[\w]{3,15}$">Only alphanum len 3-15</option>
>
>
> This simpler regex should work just as well ...
>
> <option value="^\w{3,15}$">Only alphanum len 3-15</option>
>
> <option value="^[A-Z]+.*$">Starts with capital</option>
>>
> <option value="^[0-9]+.*$">Starts with digit</option>
>>
>
> These will work fine. But "match the first character" means they can be
> slightly simpler ...
>
> <option value="^[A-Z].*$">Starts with capital</option>
>>
> <option value="^[0-9].*$">Starts with digit</option>
>
>
>
> <option value="^.+\.[a-zA-Z]{3,4}$">Extensions only</option>
>>
> <option value="^.+(\.jpg|\.gpeg)$">Extension jpg gpeg</option>
>
>
> Those look fine.
>
> There is a guide to JavaScript regular expressions at:
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
>
> TT
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/0033ae6d-9950-42c2-a5d6-f650c3e5bcec%40googlegroups.com.