Detecting new line characters
How do I detect new line and carriage return characters with
string functions like replace? It works if I actually insert a new
line in the function by pressing return, but that messes up the
formatting and makes reading the code less intuitive.
You may need to look for both chr(10) and chr(13) depending
on O/S. On *NIX you're likely to need to check for both.
Similar Messages
-
Finding New Line characters in string
Hello.
I have a textstring in which there are New Line characters. These cause problems when inserting the data.
An example is as follows (assume a table test exists with one column col1 VARCHAR2(2000):
CREATE TABLE test (col1 VARCHAR2(2000));
INSERT INTO test (col1) VALUES ('first line
second line');
INSERT INTO test (col1) VALUES ('first line' ||
chr(10) ||
'second line');
The first INSERT will fail but the second will succeed.
I want to find and replace these characters programatically in PL/SQL.
How can I edit a textstring in PL/SQL and replace the new line characters with ||
chr10) ||?
/LarsHow about this:
declare
v_oldstring VARCHAR2(50) := 'Line1'||chr(10)||'Line2'||chr(10)||'Line3';
v_tmpstring VARCHAR2(50);
v_newstring VARCHAR2(50);
begin
dbms_output.put_line(v_oldstring);
select replace(v_oldstring, chr(10), '''||chr(10)||''')
into v_tmpstring
from dual;
v_newstring := ''''|| v_tmpstring || '''';
dbms_output.put_line(v_newstring);
end; -
Replacing multiple new line characters
how to replace multiple new line characters in a line.
Suppose for example my line contains Example1#####Example2##Example3###Example4,
then the output should be Example1#Example2#Example3#Example4.Hi Sid,
You Can try this code
DATA: ld_string TYPE string,
ld_string1 TYPE string,
ld_string2 TYPE string,
ld_string3 TYPE string.
ld_string = 'Example1#####Example2##Example3###Example4'.
REPLACE ALL OCCURRENCES OF '######' in ld_string with '#'.
REPLACE ALL OCCURRENCES OF '####' in ld_string with '#'.
REPLACE ALL OCCURRENCES OF '###' in ld_string with '#'.
REPLACE ALL OCCURRENCES OF '##' in ld_string with '#'.
write:/1 ld_string.
Regards
Pavan -
How to write this logic in EL expression ? (new line characters in string
iam using JSTL EL expression in my JSP.
iam printing a string in JSP as ${vobject.rmessage} where rmessage is a string .
problem is i want to identify the newline characters in the above rmessage string and print the line break <br> in html where ever the new lines character is present in the string.
How should i write an EL expression for the above.
Can anyone please guide me on writing EL expression for the above problem?Several ways. You can wrap the output with <pre> tags. You can apply CSS property white-space: pre; to the element. You can use String#replaceAll() in the Java code to replace each occurence of "\r\n" by "<br>".
-
Replacing windows new line characters with JAVA
I am importing a file into the database... the file is written by a client using windows, and it is a text file.
When there is a windows new line character at the end of the line (^M), it is getting saved to the database as part of the string value.
When we parse this data to run a report, the (^M) are being written back out to the file and causing the fields and data not to line up.
We want to REPLACE the ^M with some other character (whatever it doesn't matter)... how can java do that???
We tried replacing '/n' with '###' and it will show the ###, but the line still breaks.
TIA,
TonyaThe characters in question are cr = \r = ascii(13) and lf = \n = ascii(10). Windows uses CrLf, Unix uses Lf and some systems use just Cr. You can use the String.replaceAll or the pattern matching classes to fix this up, see java.util.regex.Pattern, and java.util.regex.Matcher.
-
Finding nr of "new-line"-characters in string
Hi!
I looking for a smooth way of achieveing the number of "\n" characters in a string.
e.g.
String tmp = "There is a house\n in New Orleans, \n they call the Rising Sun\n";
This string should return number 3 (three occurrences of the '\n' character.
How ?
/RickardI'm not sure if this is the best way to do this but it works ok,
String tmp = "There is a house\n in New Orleans, \n they call the Rising Sun\n";
java.util.StringTokenizer st = new java.util.StringTokenizer(tmp, System.getProperty("line.separator"));
int counter = 0;
while(st.hasMoreTokens()) {
st.nextToken();
counter++;
} -
The HTMLEditor kit inserts extra newline characters when there is a space in the line and the line is greater than 80 chars? Can anyone tell me how to get rid of these extra newlines or how to set an unlimited or hugh line length as would be seen in HTML?
Thanks in advance!!Hi
I've the same problem, does anyone get a solution to this?
Thanks for your help! -
How to retain new line characters when using Node.getNodeValue()
Hi,
I have xml as shown bellow
*<DETAILS>*
this is line one
this is line two
thi is line three
*</DETAILS>*
when I parse this using dom( Node.getNodeValue() ), the value I am getting is as shown bellow
this is line onethis is line twothis is line three
but I wanted as is I have in my xml i.e,
this is line one
this is line two
this is line three
( to show that as is in HTML page)
can some body help me ??
Thanks in advance .Hi,
You could try this:
replace(your_data, chr(10), '') -
Problem with CDATA and new line character
I parse a xml document with org.w3c.dom, the document contain a CDATA section in which there are more lines of text, each line is terminated with the new line character (\n).
Example:
<nota>
<[CDATA[
first line
second line
third line
]]>
</nota>
When a parse this node:
Text txt_nota=(Text)elm_nota.getFirstChild();
String nota=txt_nota.getData();
the value returned is one string with no new line characters, example:
"first linesecond linethird line"
what's wrong?Because i use the string nota into a jsp page and i print the string nota into a textarea and the text is with no newline, example:
<textarea name="nota" rows="4" cols="60"><%= nota %></textarea>
the text into textarea is:
first linesecond linethird line
but i want that the text displayed into textarea is equal the text into the CDATA section:
first line
second line
third line -
XSLT - New Line/Carriage Return not displaying when deployed
Hello everyone,
I have an XSL Style Sheet that is supposed to transform an XML into plain text using Oracle SOA 11g BPEL transformation. The plain text transformation is working fine, but whenever I try to add a new line or carriage return, the text output doesn't reflect that. I've tried several ways of adding the line break but none of them have worked. This is the XSLT I'm using for testing purposes:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="urn:oracle:b2b:X12/V4010/850" version="1.0">
<xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
<xsl:template match="/a:Transaction-850">
<!-- New line -->
<xsl:variable name='newline'><xsl:text>
</xsl:text></xsl:variable>
<xsl:value-of select="a:Internal-Properties/a:Data-Structure/a:Property[@Name='InterchangeUsageIndicator']" />
<xsl:text>
</xsl:text>
<xsl:value-of select="$newline" />
<xsl:text>
</xsl:text>
<xsl:text> </xsl:text>
<xsl:text> </xsl:text>
<xsl:text>2000ITITM</xsl:text>
</xsl:template>
</xsl:stylesheet>
When I try it out in an online XSLT test tool, it gives the output as expected:
P
2000ITITM
When I deploy the composite, I noticed that the XSLT in the MDS repository ignores the line breaks, *#xAs, etc. and just closes the <xsl:text/> tags:
<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="urn:oracle:b2b:X12/V4010/850" version="1.0">
<xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
<xsl:template match="/a:Transaction-850">
<xsl:variable name="newline">
<xsl:text/>
</xsl:variable>
<xsl:value-of select="a:Internal-Properties/a:Data-Structure/a:Property[@Name='InterchangeUsageIndicator']"/>
<xsl:text/>
<xsl:value-of select="$newline"/>
<xsl:text/>
<xsl:text/>
<xsl:text>2000ITITM</xsl:text>
</xsl:template>
</xsl:stylesheet>
And so, because of that, it just gives me the following output:
P2000ITITM
I have no idea why it's ignoring the new line characters, so any guidance would be appreciated.
Thank you all for your help and time!
Edit: I tried concatenating as follows:
<xsl:value-of select="concat('36','
')"/>
<xsl:value-of select="concat('24','
')"/>
...which shows up as is when I look at it in the MDS repository, however the text output still shows no line breaks...
Message was edited by: dany36Ah I'm such a newbie. I was able to get it displayed by doing the following:
<xsl:variable name="newline" select="'
'" />
This would show up correctly in the MDS repository, too. -
Inserting a new line character
Hi,
In a validation routine returning a text message, I want to display all errors found separated by new line characters in the message displayed to the user. I have tried concatenating '\n' and chr(10) at the end of each message, but they do not work.
Any suggestions, please.
thanks,
PeterVikas,
I tried what you suggested, but it did not have any effect. I put the region in Region Position 1 and also tried Page template Body 1. I looked at the source generated by your example screen after the error and found this:
<tr>
<td valign="top" class="t10ContentBody"><table border="0" cellpadding="0" cellspacing="0" summary="">
<tr><td valign="top"><div class="t10messages"><div class="t10notification">1 error has occurred<ul class="htmldbUlErr"><li>Value must be specified.</li></ul></div></div><table cellpadding="0" cellspacing="0" summary=""><tr>
<td valign="top"><script type="text/javascript">
var d=getElementsByClass('t10notification');
d[0].childNodes[0].nodeValue="";
</script>
<BR><BR><BR>The segment generated in my screen looked like:
<tr>
<td class="t3PageBody"><div class="t3Messages" align="center"><div class="t3Notification">1 error has occurred<ul class="htmldbUlErr"><li>Line 3 Resolution Date
is missing<br></li></ul></div> </div><script type="text/javascript">
var d=getElementsByClass('t3notification');
d[0].childNodes[0].nodeValue="";</script>
So it looks similar but the effect is not the same. Unfortunately, I am not an html/javascript expert so the solution is not obvious to me.
thanks,
Peter -
Hello All,
I have a CLOB in my database. That CLOB contains new line characters. Now I have to remove the new lines and make the whole CLOB object as a string without the new lines.
Can anybody help in that matter ?.
Thanks and regards,
SachinCheck this code for file instead of CLOB and reply.
import java.io.*;
import java.io.FileInputStream;
import java.io.InputStream;
public class CLOBCheck {
public static void main(String[] args) throws Exception {
InputStream fis = new FileInputStream("C:\\cpsweb.log");
BufferedReader d = new BufferedReader(new InputStreamReader(fis));
StringBuffer sfr = new StringBuffer();
String line = null;
int c = 0;
while((c= fis.read())>-1){
sfr.append((char)c);
System.out.println(sfr.toString());
String a = sfr.toString().replaceAll("\n","");
System.out.println(a);
Thanks,
Sachin -
New line character when writing to a file
Hi,
I am relatively new to the whole logging aspect in JDK1.4, so this is all what I am trying to do. I have setup a logger , using the standard FIleHandler. This handler is using a custom formatter which I have written.
My formatter is very simple and the method format returns
public String format(LogRecord record)
"LogRecord info: \n" +
"Level: " + record.getLevel() + '\n' +
"SourceClassName: " + record.getSourceClassName()+ '\n' + "SourceMethodName: " + record.getSourceMethodName() + '\n' + "ThreadID: " + record.getThreadID() + '\n';
now my problem is that the File that all this gets written into does not get these new line characters, instead it has a weird symbol. I guess the \n is not being recognised correctly.
Does anyone know how to fix this.
Thanks in advance
Parulsorry about that.. I fixed it, I just used System.getProperty("line.separator");
-
New line character in c:out
hi!
I need to print a string in a table , and i am using <c:ForEach> and <c:out> tags to retrieve the data from a session scoped collection. the problem is that i need the data to be printed with new line characters to separate paragraphs, but if i put <br> into the string that i want to print it prints the word <br> and when i look at the page code, it shows the <br>�s as
How can i put new line characters using <c:out>?
thanks!!!hi!
I need to print a string in a table , and i am using
<c:ForEach> and <c:out> tags to retrieve the data from
a session scoped collection. the problem is that i
need the data to be printed with new line characters
to separate paragraphs, but if i put <br> into the
string that i want to print it prints the word <br>
and when i look at the page code, it shows the <br>?s
as
How can i put new line characters
using <c:out>?
thanks!!!ups , i mean , when i look at the page code it shows the <br> as & l t ; br / & g t ; (this is the problem) -
New line character in table View cell
tableView does not seems to accept new line characters.
I got it working in 2 ways by embedding textview or 2 labels in tableview cell.
But the problem when it gets to delete mode it doesn't move the values to right as it moves when the text is written directly on the cell. Also in textView it doesn't navigate to other view when touch happens over the area of cell covered by tableView.
Help me. Please........Write your own cell drawing code if you need to do something the default class cannot.
Maybe you are looking for
-
Download excel file to PC in background
Hi All, I need to write a report to local PC as an excel file. The program is working fine in foreground using cl_gui_frontend_services=>gui_download. However since the report data is very large, when the user runs the program in foreground, it alway
-
Dolby Digital in Flash CS4?
Hi, does someone know if it's possible to work with dolby digital in Flash CS4. Can I import audio files with 5.1 information or is Flash able to distribute mono wav-files to the different 5.1 speakers? Or is there a way to import flv-files with 5.1
-
Can i use multiple dvi monitors on the 2012 macbook pro (non-retina)?
What is the best way to connect two Dell DVI monitors I already have with my new 15" MBP (non-retina)?
-
Removing row and collumn in JTable
guys i have problem regarding JTable.. ive tried to search over the forum to find suitable answer but nothing fits in.... i need to refresh my JTable but i cant.... i've tried validate(), repaint() but it doesnt seem to work properly. this is the por
-
My hardrive has been increasingly getting louder, and in a search under Macbook Pro services I found my problem, but they said to install the Hard Drive Firmare 2.0. After I downloaded it when it opens under installer, a pop-up says 'This update is n