The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled Perl Code
Posted by: nightcracker | February 4, 2010 @ 2:49pm
Perl Code
[
Download
]
$/ = undef; $string = <>; $string =~ s{--\[\[([^\]]|\][^\]])*--[^\r\n]*\]\]|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.[^-"'\\]*)}{defined $2 ? $2 : ""}gse; $string =~ s{--[^\n\r]*|(\[\[([^\]]|\][^\]])*\]\]|"(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.([^-\["'\\]|\[[^-\["'\\])*)}{defined $1 ? $1 : ""}gse; $string =~ s{\s+|(\[\[([^\]]|\][^\]])*\]\]|"(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.([^-\s\["'\\]|\[[^-\s\["'\\])*)}{defined $1 ? $1 : " "}gse; $string =~ s{ \ ?([-+*\/%^={}().,;[\]])\ ? ## this matches every character lua doesn't care about wether a space is in front/behind of it. Example: "a = 5" equals "a=5". | ## the part that makes quotes immume to the above match ( ## open the second catch \[\[ ## an escape string opens ( [^\]]|\][^\]] ## match until closure )* \]\] ## close | " ## an quote opens ( \\. ## escaped char (to prevent closure on \") | [^"\\] ## not " or \ )* " ## close | ' ## an quote opens ( \\. ## escaped char (to prevent closure on \") | [^'\\] ## not ' or \ )* ' ## close | . ## any char ([^-\ +*\/%^={}().,;[\]\["'\\]|\[[^-\ +*\/%^={}(),;[\]\["'\\])* ## none of the things that we want to match for ) }{ defined $2 ? $2 : "$1" }gxse; print $string;
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.58 / 8
57 Votes
http://codebin.yi.org/483
page generated in 0.00 seconds