Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl -w use strict; my $format; while (<DATA>) { my $line = $_; # this line has alphbet, try to seperate if ($line =~ /[a-zA-Z\d]/) { LINE: while (1) { # (([\x81-\xfe][\x40-\xfe])*) greedy match on chinese. # line starts with chinese if ($line =~ /(([\x81-\xfe][\x40-\xfe])*)/ && $1) { my $e = $1; # update line $line = $'; $format .= ($line=~ /^\s/) ? $e : $e." "; } elsif ($line =~ /(.*?)([\x81-\xfe][\x40-\xfe])/) { # line starts with non-chinese chars my $e = $1; # the second match eats one chinese char, so get it ba +ck. $line = $2.$'; # add space after english char if it isn't ended with +space. $format .= ($e=~/\s$/) ? $e : $e." "; } else { $format .= $line; last LINE; } } } else { $format .= $line; } } print $format; __DATA__ 在 2004 年7月的开源大会时能比CPython更快的执行Python的字节码 “Perl现在生机勃勃 Perl 6被建议不应只作为Perl的新的实现 perl 5.8.x,仍然生机勃勃,Jarkko Hietaniemi今年的早些时候把 在2003年10月,发布了

In reply to format text which mixed english and chinese characters. by Qiang

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-03-29 12:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found