Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > multiline regex

Reply
Thread Tools

multiline regex

 
 
Mike Jackson
Guest
Posts: n/a
 
      10-13-2003
Hi,
I would like to convert this block of text:

(app "webserver"
(ip "1.2.3.4")
(name "foo")
(host "somehost")
)


to this:

app.webserver.ip="1.2.3.4";
app.webserver.name="foo";
app.webserver.host="somehost";


and skip processing of the entire block if the top level contains a
"no", for example:

(some_condition "no"
(foo "")
(bar "")
)


Is there already some method of doing this in perl, or is this a regex
job? Any advice?

Thanks,
Mike

 
Reply With Quote
 
 
 
 
Anno Siegel
Guest
Posts: n/a
 
      10-13-2003
Mike Jackson <(E-Mail Removed)> wrote in comp.lang.perl.misc:
> Hi,
> I would like to convert this block of text:
>
> (app "webserver"
> (ip "1.2.3.4")
> (name "foo")
> (host "somehost")
> )
>
>
> to this:
>
> app.webserver.ip="1.2.3.4";
> app.webserver.name="foo";
> app.webserver.host="somehost";
>
>
> and skip processing of the entire block if the top level contains a
> "no", for example:
>
> (some_condition "no"
> (foo "")
> (bar "")
> )
>
>
> Is there already some method of doing this in perl, or is this a regex
> job? Any advice?


What have you tried so far?

We help writing scripts, but we're not in the business of delivering
to specification.

You have nested parentheses to parse, so Text::Balanced will probably
figure in the solution.

Anno
 
Reply With Quote
 
 
 
 
Mike Jackson
Guest
Posts: n/a
 
      10-13-2003
Anno Siegel wrote:

>
> You have nested parentheses to parse, so Text::Balanced will probably
> figure in the solution.


Hi,
That was all I asked and all I wanted to know, e.g. was there already
a module that could assist in this task, or was it purely a regex task.
Thanks for the tip I'm sure that it will save me some time.

Thanks,
--
mike

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How make regex that means "contains regex#1 but NOT regex#2" ?? seberino@spawar.navy.mil Python 3 07-01-2008 03:06 PM
[2.5] Regex doesn't support MULTILINE? Gilles Ganault Python 9 07-24-2007 12:32 AM
multiline regex expression eggie5 Java 4 07-22-2007 02:09 AM
Multiline regex help Yatima Python 13 03-04-2005 02:49 AM
how to define a variable to hold a multiline text input in perl from html multiline textbox dale zhang Perl Misc 8 11-30-2004 06:53 AM



Advertisments