I want to prevent a textbox to accept only alphabets - angular6

I am designing a membership form and want only alphabets is textbox as username.
ng-pattern="/^\d{1,10}$/"
I tried it but it not works.

The pattern you're using will only get digits
/^\d{1,10}$/"
\d{1,10} matches a digit (equal to [0-9])
{1,10} Quantifier — Matches
between 1 and 10 times, as many times as possible, giving back as
needed
$ asserts position at the end of a line
If you want only alphanumeric characters try this:
/^[a-zA-Z]*$
It will accept any character a through z -- capital or lower case.

Related

Allow only 1 letter and unlimited numbers in input

So, banging my head on the wall with a regex test site and can't seem to nail this one down.
Trying to make it so an HTML is validated to only allow 1 letter maximum, but unlimited numbers, no other characters.
W123 = valid
124X = valid
1234 = valid
WW12 = invalid
Nothing incredible here, only two possible cases:
the string starts with a digit
the string doesn't start with a digit
In the two scenari only one letter is allowed.
To express that you need a group and an alternation:
^(?:\d+[A-Z]?|[A-Z]\d)\d*$
In the two branches stored inside the group, you can see that there's at least one digit (in the first because I used the + quantifier, in the second because of \d). The first branch matches any string that starts with a digit with and without a letter (because of the optional letter [A-Z]?), the second one matches strings that start with a letter. \d* at the end of the pattern matches remaining digits.
Obviously the pattern is enclosed between anchors for the start ^ and the end of the string $.
You look for zero or more digits followed by a letter followed by zero or more digits or alternatively at least one digit.
^\d*[a-zA-Z]\d*$|^\d+$

Filter only alphabetic values in tableau

I have column in tableau with following values:
1234
3456
6789
camp-1
camp-2
camp-3
I only want to show filter with values
camp-1
camp-2
camp-3
How can I only select the alphabetic values in filter in tableau?
Your example is not clear about what you want to include and what you want to exclude. To explain better, I took an elaborated example
Case-1 If you want to search/filter for digits at start, use this calculated field
REGEXP_MATCH([Field1], '^[0-9]')
Case-2 If you want to search for numbers anywhere, use this
REGEXP_MATCH([Field1], '(.*)[0-9]')
Case-3 If digits only are required
REGEXP_MATCH([Field1], '^[0-9]+$')
case-4 for alphabet at start use this
REGEXP_MATCH([Field1], '^[:alpha:]')
Results of all matches are shown below
Note Combining numbers anywhere AND alphabet at start you can filter out case1, case2 and case3 only.
Good Luck
If the Tableau column contains a mixture of numbers and text, the column will be a text column and all content will be considered as text. This reduces the problem to that of identifying specific rows that contain non-numeric values.
This requires some string manipulation and comparison. If you know that the structure of the content in those rows is predictable (eg the first character is always a letter when there are non numeric characters in the row) then a simple equation will filter on those rows:
if ascii(left([Text And Numbers],1) )>57 then 'text' else 'number' END
This exploits the observation that the ASCII decimal code for the digit 9 is 57 and most of the ASCII characters with higher codes are letters or punctuation (which is a fair assumption if nothing other than numbers, letters or punctuation are present in your data).
Obviously, if letters and numbers could appear anywhere in the string you need a more complex function but Tableau provides the option to use regular expressions which can code much more complex text analysis like is any alphabetic character present in a string (see this for some ideas of the appropriate regex expressions).

I need a regular expression that matches the following

I need a regular expression that matches the following to be used on a web page:
-The first number must be a digit
-The length must be a minimum of 10 digits
-No spaces, alpha, special characters allowed
As my understanding, you need to check if it is a number (containing only the digits 0-9) and this number should be minimum of 10 digits.
Then the following code should work:
/^\d{10,}$/

How do you match even numbers of letter or odd numbers of letter using regexp for mysql

Does anyone know how to match even numbers and odd numbers of letter using regexp in mysql? i need to match like a even number of A's followed by an odd number of G's and then at least one TC? For example: acgtccAAAAGGGTCatg would match up. It's something for dna sequencing
An even number of A's can be expressed as (AA)+ (one or more instance of AA; so it'll match AA, AAAA, AAAAAA...). An odd number of Gs can be expressed as G(GG)* (one G followed by zero or more instances of GG, so that'll match G, GGG, GGGGG...).
Put that together and you've got:
/(AA)+G(GG)*TC/
However, since regex engines will try to match as much as possible, this expression will actually match a substring of AAAGGGTC (ie. AAGGGTC)! In order to prevent that, you could use a negative lookbehind to ensure that the character before the first A isn't another A:
/(?<!A)(AA)+G(GG)*TC/
...except that MySQL doesn't support lookarounds in their regexes.
What you can do instead is specify that the pattern either starts at the beginning of the string (anchored by ^), or is preceded by a character that's not A:
/(^|[^A])(AA)+G(GG)*TC/
But note that with this pattern an extra character will be captured if the pattern isn't found at the start of the string so you'll have to chop of the first character if it's not an A.
You can maybe try something like (AA)*(GG)*GTC
I think that would do the trick. Don't know if there's a special syntax for mysql though

MS Access Input Mask for Postcode

Is there a way to set an input mask in MS Access 2007 so that certain elements are optional? UK postcodes can be in a number of formats: LL00 0LL or L00 0LL or even LL00 L00LL. For this particular assignment, I need only worry about the first two formats.
So, is there a way for me to set the input mask so that the first letter is optional?
Found an answer here and can just use the following:
LA0# oLL
A defines a letter or digit and # defines a digit or a space and removes the space when inserted into database.
Don't bother. Just use a text field and let the users insert the blanks. Put some code in checking for approriate alphabetic vs numeric characters.
The advntage is this approach will work for any country.