From owner-freebsd-questions@FreeBSD.ORG Mon Jan 5 03:50:35 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 66A7A16A4CE for ; Mon, 5 Jan 2004 03:50:35 -0800 (PST) Received: from hotmail.com (law11-f31.law11.hotmail.com [64.4.17.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4019143D46 for ; Mon, 5 Jan 2004 03:50:10 -0800 (PST) (envelope-from weiwuzhang@hotmail.com) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Mon, 5 Jan 2004 03:49:44 -0800 Received: from 218.85.104.121 by lw11fd.law11.hotmail.msn.com with HTTP; Mon, 05 Jan 2004 11:49:43 GMT X-Originating-IP: [218.85.104.121] X-Originating-Email: [weiwuzhang@hotmail.com] X-Sender: weiwuzhang@hotmail.com From: "Zhang Weiwu" To: questions@freebsd.org Date: Mon, 05 Jan 2004 19:49:43 +0800 Mime-Version: 1.0 Content-Type: text/plain; charset=gb2312; format=flowed Message-ID: X-OriginalArrivalTime: 05 Jan 2004 11:49:44.0345 (UTC) FILETIME=[02D86090:01C3D382] Subject: help me with this sed expression X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: zhangweiwu@realss.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jan 2004 11:50:35 -0000 Hello. I've worked an hour to figure out a serial of sed command to process some text (without any luck, you kown I'm kinda newbie). I really appreciate your help. The original text file is in this form -- for each line: one Chinese word then one or two English word seperated by space. I wish to change to: 1) target file: one English word, then a space, then a Chinese word coorisponding to that English word. 2) if in the original file one Chinese word has more than one English word following in the same line, repeat the Chinese word to satisfy 1). Define: Chinese word = one or more continous bytes of data where each byte is greater then 128 in value. (it is true in GB2312 Chinese charset which this email is written in.) Define: English word = one or more continous bytes of [a-z]. Say, for the original file: =========== 一a av 可歌可泣aaav 无可奉告aacm =========== The target file should be: =========== a 一 av 一 aaav 可歌可泣 aacm 无可奉告 =========== I tried to do things like s/\(.*\)\([a-z]*\)/\2 \1/ but the first \(.*\) is too greedy and included the rest [a-z]. Thank you. _________________________________________________________________ 免费下载 MSN Explorer: http://explorer.msn.com/lccn