Why we user Regular Expressions-
Regular expressions normally used for the comparison purpose.
Syntax -
{REGEX["Your Regular Expression"]}
Below are the some examples in order to generate regular expressions -
Random Number & Combinations Generation -
In automation some time we need to generate dynamic Random numbers in specific number format as per testing requirement in that case we can user below techniques to generate random numbers -
Example - Number starting with 0000 format.
Syntax - {RANDOMREGEX["Regular Expression"]}
Answer - {RANDOMREGEX["0000[0-9]{6}"]} => 0000345679
Example - Number starting with 0000 but then reset number should contain 0 in reset number. It should be 16 digit number.
Syntax - {RANDOMREGEX["0000[1-9]{12"]}
Answer - 0000136943887256
Example - Sometime we need to generate string with below format.
Payment Transaction-XXXXXX
Syntax - {RANDOMREGEX["Payment Transaction-[0-9]{6}]}
Answer - Payment Transaction-812673
Below are some sample patterns used to generate random string -
- ([A-Z][a-z][0-9]-) - Letters, numbers and hyphens.
- (\d{1,2}\/d{1,2}\/\d{4}) - Date ( e.g. 23/03/2023)
- ([^\s]+(?=\.(jpg|gif|png))\.\2) - jpg, gif or png image.
- (\w+@[a-zA-z_]+?\.[a-zA-Z]{2,6}) - Email Addresses.
- \c - Control character
- \s - White Space
- \S - Not white space
- \d - Digit
- \D - Not Digit
- \w - Word
- \W - Not word
- .\xhh - Hexadecimal character hh
- .\Oxxx - Octal character xxx
- ^ - Start of line
- \A - Start of string
- $ - End of line
- \Z -End of string
- \< - Start of word
- \> - End of word
No comments:
Post a Comment