PHP Regular Expression with Examples

Bipsmedium
3 min readSep 12, 2022
  • PHP Regular Expression is a kind of pattern that consists of a single character or a combination of more than one character.
  • It is used to search for a specific character or a combination of characters inside a string.
  • It is also used to replace some characters or some words inside a string.
  • It is also used to replace a string with another string.
  • whereas ‘/’ is the delimiter that is used to start the regular expression. This can be any character except a letter, number, backslash or spaces, etc. Sometimes if your pattern contains a forward slash then you can choose other special characters such as @#~ etc instead of forward-slash(/) as a delimiter.
  • The ‘pattern’ is the query string that needs to be searched inside another string.
  • ‘i’ is used to perform the search operation case sensitive. Suppose if you have the search pattern that is found in the main string with similar characters whether it may be in uppercase or lowercase or mixed case then the regular expression will be executed and it will return the response as 1. If your search pattern does not match the characters with the main string then the regular expression will not be executed and you will get the response as 0.

Also read, PHP JSON to Array with Example

Some important PHP regular expression functions

--

--

Bipsmedium
Bipsmedium

Written by Bipsmedium

Hi, This is Biplab and I am a PHP laravel developer and other open source technologies. I am here to share my experience with the community.

No responses yet