
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [tlug] searching for kanji strings, ignore punctuation and endof lines: Perl Solution and comments
Stephen J. Turnbull wrote:
> Perl probably has a split function; make the kanji string a varaible
> (see below for why), and split it on "" which will give you an array
> of characters. Then do a join with "\$w".
>
> (defun mung-run-perl (kanji)
> (interactive "sTarget: ")
> (search-forward "# comment on line before kanji_string"
> (forward-line 1)
> (kill-line 1) ;; remove the existing "$kanji_string =" line
> (insert " $kanji_string = " kanji ";") ; does perl need a terminating ;? whatever
> (save-buffer)
> (shell-command (buffer-file-name))
> )
>
Thats what my somewhat verbose example was doing.
$linestart='p........00.-';
@example.com = split(/ */, Encode::decode_utf8(shift));
$sep = join('','(?:\n',$linestart,'|\.)*');
$start = join('','(',$linestart,'[^\n]*', shift @example.com );
$end = '[^\n]*)';
while($_= shift @example.com){
$middle=join '',$middle,$sep,$_;
}
$regexp=join('',$start,$middle,$end);
Edward
Home |
Main Index |
Thread Index