Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Last word in line, BUT...!!! (http://www.velocityreviews.com/forums/t894380-last-word-in-line-but.html)

Mirik 09-23-2005 11:21 AM

Last word in line, BUT...!!!
 
Hi, is anybody who help me with script that I try to write?

C:\TEMP\aaa\data
C:\TEMP\bbb\data users
C:\TEMP\ccc\data WUE00024\EDV:C
C:\TEMP\ddd\data users WUE00010\EDV:X

and I want to get this:
all lines that do not contain second :, must have " at end,
all lines that contain second :, must have " before last space


like this
"C:\TEMP\aaa\data"
"C:\TEMP\bbb\data users"
"C:\TEMP\ccc\data" GIE00024\EDA:C
"C:\TEMP\ddd\data users" GOA00010\EDB:X

Thankx much.


Josef Moellers 09-23-2005 11:45 AM

Re: Last word in line, BUT...!!!
 
Mirik wrote:
> Hi, is anybody who help me with script that I try to write?
>
> C:\TEMP\aaa\data
> C:\TEMP\bbb\data users
> C:\TEMP\ccc\data WUE00024\EDV:C
> C:\TEMP\ddd\data users WUE00010\EDV:X
>
> and I want to get this:
> all lines that do not contain second :, must have " at end,
> all lines that contain second :, must have " before last space
>
>
> like this
> "C:\TEMP\aaa\data"
> "C:\TEMP\bbb\data users"
> "C:\TEMP\ccc\data" GIE00024\EDA:C
> "C:\TEMP\ddd\data users" GOA00010\EDB:X


Sigh! (looking slightly bored, drumming with my fingers on my desk) What
have you tried so far, where have you failed?
Please read the posting guidelines. This is not a "please send
money^Wcode" place.

So: post some attempts and we'll try to help.
--
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett


Brian McCauley 09-23-2005 12:09 PM

Re: Last word in line, BUT...!!!
 


Mirik wrote:

> Hi, is anybody who help me with script that I try to write?
>
> C:\TEMP\aaa\data
> C:\TEMP\bbb\data users
> C:\TEMP\ccc\data WUE00024\EDV:C
> C:\TEMP\ddd\data users WUE00010\EDV:X
>
> and I want to get this:
> all lines that do not contain second :, must have " at end,
> all lines that contain second :, must have " before last space


I shall assume you meant to include the word "inserted" (i.e. there's no
need to check if there a quote already.

I shall also assume that "second colon" can be changed to "colon after
the last space" as this makes the problem a lot simpler.

> like this
> "C:\TEMP\aaa\data"
> "C:\TEMP\bbb\data users"
> "C:\TEMP\ccc\data" GIE00024\EDA:C
> "C:\TEMP\ddd\data users" GOA00010\EDB:X


You forgot to mention you also want a " inserted at the start.

s/^(.*?)(( [^ ]*:[^ ])?)$/"$1"$2/;


Brian McCauley 09-23-2005 12:18 PM

Re: Last word in line, BUT...!!!
 
Brian McCauley wrote:

You forgot to mention you also want a " inserted at the start.
>
> s/^(.*?)(( [^ ]*:[^ ])?)$/"$1"$2/;
>


Oops. That assumes the colon is the penutimate character. Although this
was true of the OP's test data it wasn't part of the spec....

s/^(.*?)(( [^ ]*:[^ ]*)?)$/"$1"$2/;


Mirik 09-23-2005 12:37 PM

Re: Last word in line, BUT...!!!
 
wow,
thanx much for great work...
Yes I want a " inserted at the start also.
Do You read my ideas? :-)
Thanx oncemore.



All times are GMT. The time now is 06:46 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.