Easiest way to validate:
phone number format
e-mail address format
credit card number format
or anything else to check.
Using Reg-Ex you can verify, if the legitimate characters are used in the e-mail, you can also test if the domain name length is within the limit, also if the address contains at-sign character or does not contains characters (symbols) that are not possible to use in e-mail addresses.
learn moreUsing Reg-Ex for processing of credit card numbers, you can check the issuers, type, or simply verify if the card number is supported at Your shop.
learn moreMost efficient, yet easy is testing, if the phone number contains enough numbers, if there is country prefix, spaces, groups of numbers, etc.
learn moreHere in Czech Republic it is every now and then required to use forms including phone numbers for communication with clients or customers. In this case, it really needed to get their contact details as valid and correct, so you can get in touch with them later on. There is a lot of way how to type the phone number. Thus if You do not want to bother your client, it is really needed to make it as easy as possible, so pretty each format of phone number inserted is valid. Especialy if the form field with phone number is mandatory/required for data in form posting.
On the image above is shown the Regular Expression, that can settle the verification of the phone number format in order to confirm it is valid, and meets the previously mentiond local and domain lengths. The code follows in order, to allow copy it for your requirements.Using Regular Expression stated, you can "catch" phone numbers in following format:
^/((\+|)(\d{1,3}|)(\s|)(\d{9}|(\s\d{1}){9}|(\s\d{3}){3}|(\s\d{2}){1,3}))$/g
Code1: Reg-Ex for verification of phone numbers with/without international format covering all numbers to the left.
Even perfect and nicely looking e-mail address will be considered valid, if You will not set the regex to meet the allowed length before at symbol and after the at symbol (domain + TLD). If you would like to werify even such things, You have to take into consideration such stuff. Therefore, the local length (all prior the at @ character cannot be longer than 64 characters (octets) totaly, and after the at (@) symbol, 254 characters totaly. This combo makes you to create the e-mail address with total length 318 characters (-2 character from 320 characters to be on safe side). However such long e-mail provides a high chance of typing e-maill address incorrectly, if entered manualy.
On the image above is shown the Regular Expression, that can settle the verification of the e-mail address format in order to confirm it is valid, and meets the previously mentiond local and domain lengths. The code follows in order, to allow copy it for your requirements.
^[a-zA-Z.-_=\+\!]{1,63}@[a-zA-Z.]{1,200}(?:\.[a-zA-Z]{1,5}){0,2}\.[a-zA-Z]{2,24}$
Code2: Reg-Ex for verification of e-mail address including symbols and IP addresses.
In order to seek for some data, records or a line at log using Powershell, you cannot use something like IF/ELSE statement similar to the PHP or any other programming language, that supports such statements. Still, the solution exists. And that solution is Reg-Ex. So should you need to get one line from the huge log file, when some of the conditions are met, you need to configure Reg-Ex fine, to cover your demands.
On the image above is shown the Regular Expression, that can settle the verification of the e-mail address format in order to confirm it is valid, and meets the previously mentiond local and domain lengths. The code follows in order, to allow copy it for your requirements.
$profile = Read-Host -Prompt 'Enter NIA Profile ID';$profile16=$profile.PadLeft(16,'0');$profile18=$profile.PadLeft(18,'0');Get-Childitem -path 'C:\log\*secret*log' | Select-string -Pattern "\d{4}-\d{2}-\d{2}\s.*(ERROR|INFO|WARN)\s*ZR10.*(profile:\[($profile16|$profile18)\]).*\b(profile|Registry|does not exists)„;Read-Host -Prompt "Hit Enter for exit"
Code3: Powershell including Reg-Ex for searching ID in log file, based on the value entered returning DateTime stamp and the rest of the line containing the ID entered on prompt.