Regular Expressions 101

Community Library

1

Chinese Digits

Created·2024-01-05 07:56
Updated·2024-02-06 07:02
Type·Match
Flavor·PCRE (Legacy)
Match Chinese Digits less than 1×10^16, such as “一千两百三十四万”、“八萬点七六五”、“玖仟玖佰玖拾玖万玖仟玖佰玖拾玖亿玖仟玖佰玖拾玖万玖仟玖佰玖拾玖点玖玖玖玖玖玖玖玖玖玖玖玖玖玖玖玖”,Upper and lower case Chinese can be mixed, but Chinese numbers and English numbers cannot be mixed. Illegal numbers will not be matched. For example: “两十六” will not be matched, as the correct one should be “二十六”,In general Chinese, “两” and “十” are not used together; “两千零零六” will not be matched, as the correct one should be “两千零六”,as consecutive "零" in the integer part of Chinese numbers are illegal. It need a regex engine that supports the functionality of matching an expression defined in a named capture group, such as "(?[a-z]+)\d+(&letter)". 用于匹配小于1×10^16的中文数字,例如:“一千两百三十四万”、“八萬点七六五”、“玖仟玖佰玖拾玖万玖仟玖佰玖拾玖亿玖仟玖佰玖拾玖万玖仟玖佰玖拾玖点玖玖玖玖玖玖玖玖玖玖玖玖玖玖玖玖”,大小写中文数字可以混用,中文数字与英文数字不可以混用。 不合法的中文数字不会被匹配,例如:“两十六”、“两十六万”不会被匹配,因为中文习惯中不将“两”与“十”连用;“两千零零六”不会被匹配,因为其中有连续的零。 需要引擎支持引用已定义组的表达式,例如:"(?[a-z]+)\d+(&letter)"。
Submitted by Anonymous
-1

pesquisa_cautelar

Created·2023-07-14 19:37
Type·Match
Flavor·PCRE (Legacy)
Array ( [0] => Página 1 de 5 MEGA [1] => Código da Consulta: 15240795 [2] => MEGA15240795VIS\bKdKd>Z/Z\bOPRETOAGJ3548,SP,MEGA15240795VIS\bKdKd>Z/Z\bOPRETOAGJ3548,SP,MEGA15240795VIS\bKdKd>Z/Z\bOPRETOAGJ3548,SP,MEGA15240795VIS\bKdKd>Z/Z\bOPRETOAGJ3548,SP,MEGA15240795VIS\bKdKd>Z/Z\bOPRETOAGJ3548,SP,MEGA1 [3] => Data da Pesquisa: quinta-feira, 7 de julho de 2022 - 16:31:59 Data da Impressão: quarta-feira, 12 de julho de 2023 - 11:31:35 [4] => VW VW FUSCA 1600 [5] => MARCA/MODELO: VW VW FUSCA 1600 [6] => ANO FAB/MODELO: 1996 / 1996 [7] => RENAVAM: 00658362895 COMBUSTIVEL: GASOLINA [8] => CHASSI: 9BWZZZ113TP004878 [9] => PLACA: AGJ3548 [10] => COR: AMARELA [11] => CILINDRADAS: 0 [12] => MEGA BASE ESPECIAL [13] => [14] => RESUMO DAS PRINCIPAIS BASES ABAIXO [15] => RESTRIÇÕES ESTADUAL [16] => MULTAS E DÉBITOS [17] => SINISTRO [18] => HISTÓRICO DE LAUDO DE MOTOR LEIL\bO [19] => HISTÓRICO DE ROUBO E FURTO [20] => HISTÓRICO DE CONSULTAS [21] => HISTÓRICO DE LAUDO CAUTELAR [22] => ANO FABRICAÇ\bKP 1996 [23] => MARCA MODELO: VW VW FUSCA 1600 [24] => COMBUSTIVEL: GASOLINA [25] => TIPO VEICULO: AUTOMOVEL ANO MODELO: 1996 [26] => COR: AMARELA [27] => ESPÉCIE VEICULO: PASSAGEIRO [28] => CATEGORIA VEICULO: PARTICULAR [29] => PASSAGEIROS: 5 [30] => CILINDRADAS: 0 [31] => CAPACIDADE DE CARGA 0,00 [32] => QUANTIDADE DE EIXOS: 0 PROCEDÊNCIA VEICULO: NACIONAL [33] => POTÊNCIA: 53 [34] => CMT/PBT VEÍCULO: 0 / / 0 [35] => FICHA CADASTRAL [36] => DATA EMISS\bKZsP 31/05/2007 DATA LICENCIAMENTO: 04/01/2022SINISTRO [37] => ESPECIAL ROUBO E FURTO SINISTRO / [38] => ACIDENTE REMARKETING SEGURADORA / [39] => FINANCEIRA [40] => [41] => Página 2 de 5 EXER. LICENCIAMENTO: 2022 [42] => PLACA ATUAL: AGJ3548 [43] => UF PLACA: SP [44] => CHASSI 9BWZZZ113TP004878 RENAVAM: 00658362895
Submitted by emerson

Community Library Entry

1

Regular ExpressionOpen Workspace

r"
^(?:(?:(?=a+((?(1)\1)b))a)*\1)?$
"
gm

Description
Created·2024-10-14 01:17
Type·Match
Flavor·Python

Matches some number of a's followed by the same number of b's, usually written as a^nb^n for all natural numbers n. For regular expressions as formally defined in formal language theory, this is impossible , but modern day regex engines can do far more than match just regular languages. Note that even though this works with the Python flavor on regex101, this doesn't actually compile with Python's re library, since their regex engine doesn't allow you to:

  1. Lazily evaluate conditional groups: (?(1)\1) requires \1 to exist, even though if it doesn't exist the pattern would just match nothing and keep parsing.
  2. Reference open groups: This is kind of related to the previous one, since we need to reference the previous value of a group within itself, and we need to use a conditional for before the group first matches anything. As per 1, this requires the group to exist even if we don't use the value, hence it doesn't work.

Here is a short explanation on how the regex works: The key part of the regex is this lookahead (?=a+((?(1)\1)b)) wrapped by ((?=...)a)*. The lookahead skips through the a's, and then group one ((?(1)\1)b)) matches either b if group one doesn't exist (the first "iteration", where we iterate via the outer *), or group one and a b if it does exist. The effect of this is that we iterate the * group until either we run out of b's or we run out of a's. After that, we just need to check that we have group one followed by the end of the string at the end, since those are the b's. If we have too many a's, we would be matching against a...b...b, and if we have too many b's we wouldn't hit the end of the string. One small caveat is that if we have an empty string, group one doesn't exist, which we can remedy by either putting (?(1)\1) or just wrapping everything in an optional group.

Submitted by FieryIceStickie
Open Workspace