Dari Tutorial Regex - Karakter Literal dan Karakter Khusus:
Karena kami ingin melakukan lebih dari sekadar mencari potongan teks literal, kami perlu menyisihkan karakter tertentu untuk penggunaan khusus. Ada setidaknya 12 karakter dengan makna khusus:
backslash \, caret ^, tanda dolar $, titik atau dot ., bar vertikal atau simbol pipe |, tanda tanya ?, asterisk atau star *, tanda plus +, tanda kurung buka (, tanda kurung tutup ), tanda kurung siku buka [, dan tanda kurung kurawal buka {, Karakter khusus ini sering disebut “metakarakter”. Sebagian besar dari mereka adalah kesalahan jika digunakan sendirian.
Jika Anda ingin menggunakan salah satu karakter ini sebagai literal dalam regex, Anda perlu escape (menambahkan backslash) dengan backslash. Jika Anda ingin mencocokkan 1+1=2, regex yang benar adalah 1\+1=2. Jika tidak, tanda plus memiliki makna khusus.
Dan di PT, kami sering membutuhkan \ dalam regex, karena ini sangat mendasar bagi usfm. Jadi untuk mencari \p dalam regex, Anda mengetik \\p.
(Mempelajari tentang escape itu berguna, karena bahkan di alat forum ini, karakter tertentu tidak akan dirender, kecuali Anda escape atau menggunakan fitur “teks terformat” melalui ikon </>.)
From a Regex Tutorial - Literal Characters and Special Characters:
Because we want to do more than simply search for literal pieces of text, we need to reserve certain characters for special use. There are at least 12 characters with special meanings:
the backslash \, the caret ^, the dollar sign $, the period or dot ., the vertical bar or pipe symbol |, the question mark ?, the asterisk or star *, the plus sign +, the opening parenthesis (, the closing parenthesis ), the opening square bracket [, and the opening curly brace {, These special characters are often called “metacharacters”. Most of them are errors when used alone.
If you want to use any of these characters as a literal in a regex, you need to escape them with a backslash. If you want to match 1+1=2, the correct regex is 1\+1=2. Otherwise, the plus sign has a special meaning.
And in PT, we often need the \ in a regex, because it is so fundamental for usfms. So to search for \p in a regex, you type \\p.
(It is useful to learn about escaping, as even in this forum-tool, certain characters will not render, unless you either escape them or use the “preformatted text” feature via the </> icon.)
Diterjemahkan secara otomatis dari English