Replace regex with ProgramAsWeights: one-liner email validation

yuntiandeng · x · 2026-08-06

Developer yuntiandeng shares an example of using the ProgramAsWeights library to replace regex:

python

import programasweights as paw

fn = paw.compileandload("check whether a string looks like a valid email address")

fn("[email protected]") "valid"

fn("abc@def") "invalid"

The library compiles natural language descriptions into executable functions, simplifying pattern matching tasks.

Original post →

More from coding & agent

coding & agent channel →