Search Pattern with ⎕UCS 13

General APL language issues

Search Pattern with ⎕UCS 13

Postby PGilbert on Wed Aug 06, 2014 12:03 pm

What would be the proper way to change all the carriage return (⎕UCS 13) of a vector of character while using ⎕R. I have tried the following but it is not working:

Code: Select all
((⎕ucs 13) ⎕R '\
')  'first line',(⎕ucs 13),'second line'
('\r' ⎕R '\
')  'first line',(⎕ucs 13),'second line'


Thanks in advance
User avatar
PGilbert
 
Posts: 436
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: Search Pattern with ⎕UCS 13

Postby DanB|Dyalog on Wed Aug 06, 2014 8:01 pm

Hi Pierre,
⎕S/R work in Line mode (the default) and Document mode.
In Line mode each line is treated individually as if they were split on CRs.
In document mode every character is visible and can be acted upon.
There is more to it but to answer your problem use the Document Mode variant:

Code: Select all
 ((⎕ucs 13) ⎕R '\
'⍠'Mode' 'D')  'first line',(⎕ucs 13),'second line'
first line
second line
DanB|Dyalog
 

Re: Search Pattern with ⎕UCS 13

Postby PGilbert on Wed Aug 06, 2014 10:21 pm

Many thanks Daniel it worked perfectly. For the benefits of everybody here is the resulting DFN that can be used to change the characters that are not allowed in xml (when not using ⎕XML that does it automatically):

Code: Select all
{((⎕UCS 13) ⎕R '\&#10;' ⍠ 'Mode' 'D')('<' ⎕R '\&lt;')('>' ⎕R '\&gt;')('&' ⎕R '\&amp;')⍵}
User avatar
PGilbert
 
Posts: 436
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest