Re: regexps
- Posted by Andy Kurnia <akur at DELOS.COM> Jul 06, 1998
- 503 views
At Sun, 5 Jul 1998 17:05:58 EDT, Buddy Hyllberg <budmeister1 at JUNO.COM> wrote: >wow! a reply ;) >I'm not exactly sure you want to use them in Euphoria. In Perl, regexps >are usually used for substitution, matching or comparison: > ># changes $var to lowercase >$var = 'Hi there'; >$var =~ tr/A-Z/a-z/; > ># checks for answer yes (or similar) >$var = 'yes'; >print "Good job" if $var =~ m/yes/; > > >what exactly did you want to use them for? >same thing maybe... ;) That, and more... I want all ?? (one-time matching) syntax: ?PATTERN? m// (matching) syntax: m/PATTERN/gimosx // (matching) syntax: /PATTERN/gimosx q// (single/direct quoting, maybe unnecessary) syntax: q/STRING/ qq// (double/interpolated quoting, will substitute embedded vars etc) syntax: qq/STRING/ qx// (backquoting: execute, and return stdout) syntax: qx/STRING/ qw// (list of words, can be simulated quite easily in Euphoria) syntax: qw/STRING/ s/// (substitution) syntax: s/PATTERN/REPLACEMENT/egimosx e.g. s/do/did/g used on "Can we undo what he does?" will give you "Can we undid what he dides?" tr/// (translation) syntax: tr/SEARCHLIST/REPLACEMENTLIST/cds y/// (translation) syntax: y/SEARCHLIST/REPLACEMENTLIST/cds tr/// = y/// m// = //