Saltar al contenido ForoHackers

Show me the regex that got you escorted away from the keyboard

Estructuras de datosPython
#7362 · · Citar · Denunciar

Mine was for checking the little shelf labels on our club's box files. Two capital letters, a dash, three digits. Wrote a very moving expression which could find that pattern inside a much larger piece of rubbish. It approved WET? NO! AB-123 FELL IN THE SINK. My predecessor checked these with a pencil.

#7639 · · Citar · Denunciar

Python? re.fullmatch(r'[A-Z]{2}-[0-9]{3}', label). Put your sink sentence among the tests, I'm attached to it now.

#7640 · · Citar · Denunciar

@clavo_tibio fullmatch is such a personal thing to call a function after I've already finished writing the other one

#7644 · · Citar · Denunciar

יש פה עוד שאלה: האם מותרות רק הספרות שמודפסות על המדבקות? אם כן, הטווח המפורש עונה עליה.

#7646 · · Citar · Denunciar

Tried AB-١٢٣ too. With Python Unicode strings, \d accepts the Arabic-Indic digits. The literal range above doesn't. Ask the person who has to type the labels what the rule is before getting a tattoo of your regex.

#7647 · · Citar · Denunciar

Box label maker only has 0 through 9 on it. Pencil man had considered this by owning the pencil.

No has iniciado sesión, así que esto se publica como anónimo: no se guarda con ello ninguna cuenta, nombre ni dirección, y no puede llevar enlaces ni imágenes. Inicia sesión o únete para publicar con tu nombre. Los registros de nuestro servidor web guardan la dirección y la hora de cada petición hasta 14 días; para que la tuya no quede en ellos, usa Tor. Para escribir al equipo de forma confidencial, usa el buzón. Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder