Examples of Regular Expression Block Code

196 views 2 pages ~ 387 words Print

According to (Philip and Gørtz 2018) Regular Expressions are codes used in many computer programs to model the input data into the desired format. This code dictates the format of the input data for database sovereignty purposes – it checks on the format of the input on the client side before further validation by database functions. This simplifies the execution of database process as any input not matching the predefined format is rejected automatically. In this paper, we describe examples of regular expression block code. The purpose of this paper is a guide to quick reference on important regular expressions

In this section, we discuss regular expressions for formatting the following input data;

Email

Phone number and,

 Social Security Number

Regular Expression for Validating Email Addresses. We use ^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$  as regular expression when validating any email address. It is an easy expression that checks for an accepted format for the email address. It matches email addresses such as [email protected] (Jon and Uckelman).

Regular Expression for Validating Phone Numbers. We use ^0[1-6]{1}(([0-9]{2}){4})|((\s[0-9]{2}){4})|((-[0-9]{2}){4})$ regular expression to validating some phone numbers. This regular expression gives a validity for phone numbers of the form 01-46-70-89-12 | 0146708912 | 01 46 70 89 12 |, but rejects phone numbers of the form | 01 46708912 | 01-46708912 | +33235256677 and other types not conforming to the predefined format.

Regular Expression to Validate Social Security Number. We use ^\d{3}-\d{2}-\d{4}$ regular expression to validating hyphen-separated Social Security Number (SSN) in the format NNN-NN-NNNN. This regular expression matches 333-22-4444 | 123-45-6789, but rejects 123456789 | SSN (Daniel and  Leibman 20145).

The following hyperlink will assist in getting some regular expressions https://help.libreoffice.org/Common/List_of_Regular_Expressions.

Conclusion      

Regular defines the specific format in which input data should confirm before accepted as a valid input both by client-side and backend program. It is important to validate data before feeding into the system to meet the accepted format by database schemes.

Work Cited

Bille, Philip, and Inge Li Gørtz. “From Regular Expression Matching to Parsing.” arXiv preprint arXiv:1804.02906 (2018).

Stewart, Jon, and Joel Uckelman. “Multipattern regular expression search systems and methods therefor.” U.S. Patent Application No. 15/664,056.

Wyschogrod, Daniel, and Leonid Leibman. “System and method for determining the start of a match of a regular expression.” U.S. Patent No. 9,043,272. 26 May 2015.

September 04, 2023
Subject area:

Computer Science

Number of pages

2

Number of words

387

Downloads:

25

Writer #

Rate:

4.7

Expertise Computer Science
Verified writer

Richard is the best writer for Data Science tasks, even if you have something really complex. I needed to do tasks on security matters and already had a draft. Sharing my ideas with Richard ended up in a perfect paper!

Hire Writer

Use this essay example as a template for assignments, a source of information, and to borrow arguments and ideas for your paper. Remember, it is publicly available to other students and search engines, so direct copying may result in plagiarism.

Eliminate the stress of research and writing!

Hire one of our experts to create a completely original paper even in 3 hours!

Hire a Pro