очень важно документировать, когда кто-то использует регулярные выражения, чтобы другие могли понять
Как вы видите на выходе
P.O. BOX 123 is converted into PO BOX 123
Объяснение некоторых важных вещей, используемых и используйте эту ссылку, чтобы понять в деталях
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003288497.htm
? indicates something is present 0 or 1 time
example: "do(es)?" matches the "do" in "do" or "does"
period(.) is another metacharacter it means any single character in regex
to address period it has to escaped using \ it becomes \.
\s indicates space
В prxchange это захваченная группа "0? \ S? P. \ s? O. BOX:?" который заменяется на / PO BOX /
0? can have zero or may not have in start
followed by \s that is space \s? indicates it can be there or not.
followed by literal P followed by . that is P.
followed by space or no space and literal 0 followed by .
folloed by space and Box and can have : or not
Это охватывает следующие несколько различных сценариев / паттернов
"0 P.O. BOX" will converted into PO BOX
"0 P.O. BOX:" will converted into PO BOX
"P.O. BOX:" will converted into PO BOX
"0 P.O. BOX" will converted into PO BOX
"P.O. BOX" will converted into PO BOX