[racket] issue with function "regexp-replaces"
If you only use (regexp-...) the return values are implicitly
printed by the module and the module uses (print ...).
Compare
(print "\n")
(display "\n")
See docs on
#%module-begin
for more
On Fri, 07 Jun 2013 17:04:38 +0200, Sanjeev K Sharma <throwit1 at gmail.com>
wrote:
> sorry, I did that too quick
>
> I'm getting something working doing this
>
> (display (regexp-replace* ...
>
> I'll have to figure out now why (regexp-replaces ...) doesn't give me
> the same.
>
>
> ______
>
> On Fri, Jun 07, 2013 at 10:58:06AM -0400, Sanjeev K Sharma wrote:
>> thanks for the quick response, I can't get newlines in the output
>>
>> program:
>> #lang racket
>> (display "inpu#\nt-str#\ning#\n\n")
>> (printf"~a~a~n""printf""inpu#\nt-str#\ning\n")
>> (printf"~a~a~n""printf""inpu\nt-str\ning\n")
>> (regexp-replace* "\n" "inpu#\nt-str#\ning#\n " "\n<br>")
>> (regexp-replace* "\n" "inpu#\nt-str#\ning#\n " "\\n<br>")
>> (regexp-replace* "\n" "inpu#\nt-str#\ning#\n " "#\n<br>")
>> (regexp-replace* "#\n" "inpu#\nt-str#\ning#\n " "#\n<br>")
>> (regexp-replace* "#\n" "inpu#\nt-str#\ning#\n " "#\\n<br>")
>> (regexp-replace* "#\n" "inpu#\nt-str#\ning#\n " "#\\\n<br>")
>>
>> ____________
>> output:
>> Welcome to DrRacket, version 5.3.4 [3m].
>> Language: racket; memory limit: 10000 MB.
>> inpu#
>> t-str#
>> ing#
>>
>> printfinpu#
>> t-str#
>> ing
>>
>> printfinpu
>> t-str
>> ing
>>
>> "inpu#\n<br>t-str#\n<br>ing#\n<br> "
>> "inpu#\nn<br>t-str#\nn<br>ing#\nn<br> "
>> "inpu##\n<br>t-str##\n<br>ing##\n<br> "
>> "inpu#\n<br>t-str#\n<br>ing#\n<br> "
>> "inpu##\nn<br>t-str##\nn<br>ing##\nn<br> "
>> "inpu##\n\n<br>t-str##\n\n<br>ing##\n\n<br> "
>> >
>>
>> (just throwing random numbers of # and \\ in to see what I'm
>> misunderstanding)
>>
>> On Fri, Jun 07, 2013 at 09:24:07AM -0400, Sean Kanaley wrote:
>> > (regexp-replace* "\n" input-string "\n<br>")
>> >
>> > would be the target expansion for those pairs.
>> >
>> > On 06/07/2013 08:57 AM, Sanjeev K Sharma wrote:
>> > >I have to clean up a bunch of source files that don't show properly
>> > >
>> > >I have a file from which I'm reading a bunch of regular expressions
>> to replace, things like this:
>> > >
>> > >(#px"(?i:%5C)""/")
>> > >
>> > >but included in the same file (full of from-to pairs) are a bunch of
>> straight string replacements, like this:
>> > >
>> > >("…""\\…")
>> > >
>> > >
>> > >I cannot figure out what's wrong with this one: what to do here
>> > >
>> > >("\n""\n<br>")
>> > >
>> > >it replaces the starting "\n" but never puts in the replacement "\n"
>> > >
>> > >I've doubled/tripled/quadrupled on the backslashes
>> > >
>> > >("\n""\\n<br>")
>> > >("\n""\\\n<br>")
>> > >
>> > >but that doesn't put in a newline, rather two separate characters,
>> "backslash" and "n"
>> > >
>> > >any hints what I'm doing wrong here?
>> > >____________________
>> > > Racket Users list:
>> > > http://lists.racket-lang.org/users
>> >
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users
--
---------------------------------------------------------
Tobias Hammer
DLR / Robotics and Mechatronics Center (RMC)
Muenchner Str. 20, D-82234 Wessling
Tel.: 08153/28-1487
Mail: tobias.hammer at dlr.de