CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
interesting regex challenge

 



soeeom
New User

Jul 1, 2011, 2:33 PM

Post #1 of 2 (2637 views)
interesting regex challenge Can't Post

I'm not sure if you can call it a challenge but the nature of regex is challenging, at least to me Tongue.

Anyway I have a string like this:
$string = '^i&jf'e%o@#]ed=fng&dwp3tll1"h2\3r5@~@:'

what I want to do is (it's crazy) strip all the special characters and numbers out of the string, I can do that using \(?[^a-z]|(?<=['\"]) apart from the quotation mark, not sure how to do this, then im left with a quotation mark and some random letters, from this using regex i want to code print "hello"; then i'll use eval to execute it.

I know its insane and sounds pointless but i'm just very interested in doing this, i've tried for ages but kept failingCrazy is this even possible by just using mostly regex?

thanks

ps: been using http://gskinner.com/RegExr/ to test the regex patterns, its quicker.


(This post was edited by soeeom on Jul 1, 2011, 2:35 PM)


miller
User

Jul 7, 2011, 3:03 PM

Post #2 of 2 (2400 views)
Re: [soeeom] interesting regex challenge [In reply to] Can't Post


Code
my $string = q{^i&jf'e%o@#]ed=fng&dwp3tll1"h2\3r5@~@:}; 

$string =~ s/[^a-zA-Z]//g;

print $string;


- Miller

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives