Validate Email Or Number in Regex - regex

I have a sign in form where userid is email id of users or unique id given by us i.e in integer.
So i want regex for that text box to validate email or Id.
Means.
if someone enters
abc#abc.com
or
1024
then it is valid
and if someone is entering anything other than email or integer than it should show as invalid.
Thanks...

^(?:[\w.]+#[\w.]+|\d+)$
You can try this.Though Your requirements are not very clear.See demo.
http://regex101.com/r/zU7dA5/4

Related

How to set a x-header in OTRS6 Postmaster filter with regexp?

I am trying to set the x-header for a dynamic field to the first number found in the e-mail subject with a regexp ^[^\d]*(\d+).
I can't figure out the right syntax for the set email header value field:
This is a working example. It extracts the first number found in the Subject and adds it to the dynamic field. How this is done is also explained in the hint on the left site
If the Subject of the Mail is "test 124 14 test 44", then the dynamic field has the Value "124"

Invalid Cognito Phone Number

We have been trying to upload users to cognito via the import jobs. However, seems like the phone_number attribute refuses to accept Indian mobile numbers. The format for phone number is like +919839999999. The phone_number_verified field is set to TRUE. Below is the error I receive:
[FAILED] Line Number 21 - The User Record contains an invalid phone number for the phone_number attribute.
From the documentation, cognito does say that after first two characters of country code, it looks for area code but I am not sure if that'll be the case when using cellphone numbers.
It seems if you are using google sheets, you have to re-convert the format to text of the cellphone fields or manually edit the csv. It works then

Email Validation to avoid duplicate entry within two items Apex

I am having two items:
P1_email
p2_emails
Here I want to validate the email ids, the same email ids should not enter with these items.
If I enter same email id in both items, it should raise an error:
its not possible to enter the same email id in both place.
The simplest option is to create validation on P2_EMAILS item. Choose PL/SQL Function (returning error text). Code to be used:
if :P1_EMAIL = :P2_EMAILS then
return ('It is not possible to enter the same email ID in both places');
end if;
Note that this won't handle invalid e-mail addresses (such as "little#foot#gmail#com"), NULLs etc. - as I said, it is the simplest way to do what you asked.

Oracle Apex email validation

I have an item to enter the email ids item_email
I need to give validation for email id item item_email that the email id should not exists already in table.
So I have to create email validation please help me to proceed on this.
You need to create a Validation (Processing tab) with type No Rows Returned, and put the following to the validation query:
select 1
from table_with_emails
where email_column = :P_EMAIL_ITEM
UPD
To check email: create a new validation (it is easier than add two checks in one) with type PL/SQL Expression, and add the following:
regexp_like (:P_EMAIL_ITEM, '^[A-Za-z]+[A-Za-z0-9.]+#[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$')
Creating a new validation also allows you to define two different error messages: when email is already exists and when it has wrong format.
Additionally, consider creating UNIQUE INDEX on e-mail column. Apex validation would do the job, but won't prevent another ways of inserting data.

Encryption using passlib.hash - sha256_crypt.encrypt and decryption

I am taking password inputs from user and planning to use passlib.hash library for encrypting the password .
I am able to encrypt the password successfully and their documentation states about the verify function usage, however I want to find out the original password entered , Is it possible ?
For example :
User entered a password : abcd
Password encrypted using passlib to a variable hash
How to decrypt the password hash and get value abcd ?
See the sample code below :
print "Enter a password "
passw = raw_input()
print "password entered is ", passw
hash = sha256_crypt.encrypt(passw)
retrivepass=?
Is it possible to retrive the original password ? If not what is the best alternative ?
Thanks in advance
Is it possible to retrieve the original password?
No. The purpose of a password hashing function is to make it possible for you to authenticate users without actually storing their passwords.
Hashing functions are one-way, so given the output, you cannot infer what the input was. Think of it like adding two numbers together. You know that 2 + 2 = 4, but given 4, you can't figure out that the two numbers that were added together were 2 and 2.
If not what is the best alternative?
You most likely don't need encryption. You need a good password hashing function, like Bcrypt or PBKDF2.
Store the hash then when the user would like access:
valid = False
while not valid:
passw = raw_input("Enter your password")
valid = sha256_crypt.verify(passw, hash)
Hashing is the process of encrypting standard blocks of data, which often results in the same length of output, with even infinitely long input. SHA256 encodes input data into 256 bits of output data.
You can always hash the password and store it. But the password cannot be retrieved back. The ideal way is to get the password again, hash it, and compare it with the stored hashed value.