A simple question in regular expression

I need to find a bunch of files for everything that contains "tblPayment" or "tblInvoice"

I also want to match any tables with the name "tblPaymentMethod", "tblInvoiceItem", "tblInvoicePayment"

Anyone want to help me write a regex for this?

Thanks again!

+3
source share
6 answers
tbl(Invoice|Payment)+

it will also match tables without a table prefix if you need this flexibility.

: (.. tblInvoice|tblPayment|...), RegEx , , . , , - , .

+4

.

tblPayment|tblInvoice|tblPaymentMethod|tblInvoiceItem|tblInvoicePayment

, .

0
tbl(Payment(Method)?|Invoice(Item|Payment)?)

, , , , .

0

Perl RE:

/tbl
 ((Payment(Method)?)
 |
 (Invoice(Item|Payment)?))
/x

, .

0

python - :    "TBL (- | )? +"

0

If you want to match any table name that starts with tblInvoice or tblPayment, then this will do:

tbl(?:Invoice|Payment)\w*

(?: Invoice | Payment) is a non-capture group (more effective in this case than a capture group). And then \ w * will not necessarily match the alphanumeric characters following it.

0
source

Source: https://habr.com/ru/post/1745144/


All Articles