perl-ish regexps?
- Posted by Tom Eklof <darkspace at GNWMAIL.COM> Jul 18, 1999
- 505 views
Yes, I'm back again. Be afraid, be very afraid.. I was wondering if anyone would be willing/capable of implementing perl- like regexps, in a function called regex() or something? Yes, I know, perl and its regexps look like line noise, but typing result =3D regex({^\(d).?\1$}, myVar) (and I use {} instead of // as in perl {RE} vs. /RE/) is rather easier than the euphoria equivalent of.. well... whatever. (The regexp in question would find a 'word' that starts with a digit and possibly has a string of characters after it, and ends with the same digit).= You could make the function either return the closest match, or return all the matches if the user so desires (result should be an object?) This could make things easier for the database (and such) inclined. And adding the substitute function would be totally brilliant, so removing, for example, excessive whitespace from scripts, formatting text to whatever you want and such would be so much easier. sequence x x =3D "spaces a plenty" x =3D subst({\s+}, {\s}, x) x whould be "spaces a plenty" (unless I messed up the regexp, which of course is highly possible). x =3D "m5439'.e5588/#s...-*''s009989/&a785784g=B4654677,,.^^=A8=A8=A8~~e" x =3D subst({[^a-zA-Z]}, {}, x) x would amount to "message" (ooh! Aaaah! Uuuuuuh!) Any thoughts on this? Just my 0.0000341792 cents.... --Tom Ekl=F6f DO .1 <- "^'"^.3$.3"~"#0$#3906"'$'"^.3$.3"~"#0$#3906"'"~"#0$#3906"