From: Sooraj S on
Hi,

My data file :
-------------------
// abc def
//
// abc dser
//
----------------------
i want to remove the lines 2 and 4 from the file.

check criteria : line should start with // and one or more spaces only
as the other characters.

i tried this .. if (/^\/\/(\s)*/ ... but it shows entire lines..

How to do it using regular expressions ? Is there any way to find the
end of a word using regular expressions ?
From: J�rgen Exner on
Sooraj S <soorajspadmanabhan(a)gmail.com> wrote:
>Hi,
>
>My data file :
>-------------------
>// abc def
>//
>// abc dser
>//
>----------------------
>i want to remove the lines 2 and 4 from the file.
>
>check criteria : line should start

^

> with //

//

>and one or more spaces only

+ (that is a space character followed by a plus sign)

>as the other characters.

$

So the whole RE becomes
(^// +$)

>i tried this .. if (/^\/\/(\s)*/ ... but it shows entire lines..
>
>How to do it using regular expressions ?

You are plenking.

>Is there any way to find the
>end of a word using regular expressions ?

Sure, from 'perldoc perlre':

Assertions
Perl defines the following zero-width assertions:
\b Match a word boundary

But what does that question have to do with your earlier problem
statement?

jue
From: Steve C on
J�rgen Exner wrote:
> Sooraj S <soorajspadmanabhan(a)gmail.com> wrote:
>> How to do it using regular expressions ?
>
> You are plenking.
>

Thanks for the new word.

From: J�rgen Exner on
Steve C <smallpond(a)juno.com> wrote:
>J�rgen Exner wrote:
>> Sooraj S <soorajspadmanabhan(a)gmail.com> wrote:
>>> How to do it using regular expressions ?
>>
>> You are plenking.
>
>Thanks for the new word.

Nothing new about it: http://en.wikipedia.org/wiki/Plenk

jue
From: Justin C on
On 2010-06-29, Sooraj S <soorajspadmanabhan(a)gmail.com> wrote:
> Hi,
>
> My data file :
> -------------------
> // abc def
> //
> // abc dser
> //
> ----------------------
> i want to remove the lines 2 and 4 from the file.
>
> check criteria : line should start with // and one or more spaces only
> as the other characters.
>
> i tried this .. if (/^\/\/(\s)*/ ... but it shows entire lines..
>
> How to do it using regular expressions ? Is there any way to find the
> end of a word using regular expressions ?

I think you want a '+' where you have '*'. '*' means 'any number of
times including 0'. '+' means 'at least once'.

However, that will still match the lines that you want to keep. You have
the '^' to match at the beginning of the string. If only there was
something to match the end of the string...

Justin.

PS Regex word boundary = \b
--
Justin C, by the sea.