March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
9
Task/Multisplit/AutoHotkey/multisplit.ahk
Normal file
9
Task/Multisplit/AutoHotkey/multisplit.ahk
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
Str := "a!===b=!=c"
|
||||
Sep := ["==","!=", "="]
|
||||
Res := StrSplit(Str, Sep)
|
||||
for k, v in Res
|
||||
Out .= (Out?",":"") v
|
||||
MsgBox % Out
|
||||
for k, v in Sep
|
||||
N .= (N?"|":"") "\Q" v "\E"
|
||||
MsgBox % RegExReplace(str, "(.*?)(" N ")", "$1 {$2}")
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
#!/usr/bin/perl -w
|
||||
use strict ;
|
||||
sub multisplit {
|
||||
my ( $string , $pattern ) = @_ ;
|
||||
split( /($pattern)/, $string, -1 ) ;
|
||||
my ($sep, $string, %opt) = @_ ;
|
||||
$sep = join '|', map quotemeta($_), @$sep;
|
||||
$sep = "($sep)" if $opt{keep_separators};
|
||||
split /$sep/, $string, -1;
|
||||
}
|
||||
|
||||
my $phrase = "a!===b=!=c" ;
|
||||
my $pattern = "==|!=|=" ;
|
||||
print "$_ ," foreach multisplit( $phrase , $pattern ) ;
|
||||
print "\n" ;
|
||||
print "'$_' " for multisplit ['==','!=','='], "a!===b=!=c";
|
||||
print "\n";
|
||||
print "'$_' " for multisplit ['==','!=','='], "a!===b=!=c", keep_separators => 1;
|
||||
print "\n";
|
||||
|
|
|
|||
2
Task/Multisplit/TXR/multisplit-2.txr
Normal file
2
Task/Multisplit/TXR/multisplit-2.txr
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
$ txr -p '(tok-str "a!===b=!=c" #/==|!=|=/ t)'
|
||||
("a" "!=" "" "==" "b" "=" "" "!=" "c")
|
||||
Loading…
Add table
Add a link
Reference in a new issue