Welcome to Stackoverflow. This seems to be a pretty fundamental question to me, therefore I'd like to answer it with some off-site resources as you already learned about Stackoverflow and could search it your own (it is a FAQ-like Question & Answer site):
- These are, as you have rightfully identified your own, Patterns.
- More specifically these are Regular Expression patterns (or called that way).
- In concrete in PHP with
preg_replace()
they are in the Perl Compatible Regular Expression (PCRE) dialect.
- The
preg_*
in front of preg_replace
stands for (at least this is how I explain it to myself) Perl REGular expressions or as the PHP Manual words it "Regular Expressions (Perl-Compatible)", see https://www.php.net/pcre .
How is it written this pattern?
Like outlined in the PHP manual. (no pun intended)
What do the characters here mean?
The PHP manual has a short version (it is introductory) of the PCRE syntax. Start reading there (see PCRE Patterns (PHP Manual). The full syntax is documented with the PCRE library itself that you find available (bound) with PHP, for example the PCRE 2 manpage on the libraries homepage.
If you're using a supported PHP version, this is PCRE2. If not, it can vary. Nevertheless, the basics of those pattern are explained both in the PHP manual as well as on the PCRE website. It should provide enough text to read.
Remember that you can always create yourself small PHP scripts to try out things in PHP (and therefore with such patterns).
Additionally, literature exists available to study - even when offline and (out of electrical energy) at daylight (very comfortable!).
If you're out of luck finding literature, benefit from being online and having a printer at hand and print out the manual pages.
If you're lucky, your operating system ships with the documentation at pcre(3)
or similar.
Good luck and thanks for asking!