How to replace " ' " in string
IF GT_REP-SERNR CA ' ' '.
REPLACE ' ' '' IN GT_REP-SERNR WITH SPACE.
ENDIF.
Can you please give me ur answers? i am getting syntax error.
i have to replace ' with space in '000123.
e.g : input = '000123
output = 000123
how to do in abap logic ?
Hi,
You can do this using Hex Characters.
The hex value for Single Quote is '27'.
Sample Code:-
*== Declare a Hex Type Variable, Char Type Variable
DATA : LC_HEX TYPE X VALUE '27', LC_CHAR TYPE C,
LR_CONV TYPE REF TO cl_abap_conv_in_ce.
*== USE THIS METHOD FOR HEX-CHAR CONVERSION
CALL METHOD cl_abap_conv_in_ce=>create
EXPORTING
encoding = 'UTF-8'
input = lc_hex
RECEIVING
conv = LR_conv.
CALL METHOD LR_CONV->read
EXPORTING
n = 1
IMPORTING
data = lc_char. "-- AT this point, LC_CHAR will contain the value ' (single quote)
REPLACE FIRST OCCURRENCE OF lc_char IN lc_text WITH space.
This will work, try it out.
Regards
Dedeepya C
Edited by: dedeepya reddy on Mar 23, 2010 6:25 AM
Similar Messages
-
How to replace the string in a file
Hi, I have a file which contains the following data
File.dat
<file>
<filenum>
W10
</filenum>
<hello>Heading </hello>
</file>
I need to replace the contents of file.dat
database sequence value (for example xx_seq.nextval)
Can some one please tell me how to search this <filenum>
W10</filenum>
and replace this with xx_seq.nextval
and write the entire contents of the file to new file
I am doing some thing like this
suppose if my database value returns 11 from the above sequence then
the output should be in file2.dat as
<file>
<filenum>
11</filenum>
<hello>Heading </hello>
</file>
declare f_in utl_file.file_type;
s_in varchar2(10000);
string1 varchar2(32000);
x number;
begin
f_in := utl_file.fopen('SAMPLEDIR','input.txt','R');
f_in1 := utl_file.fopen('SAMPLEDIR','input1.txt','W');
select xx_seq.nextval into x from dual;
loop
begin utl_file.get_line(f_in,s_in);
EXCEPTION
WHEN NO_DATA_FOUND THEN
EXIT;
string1:= string1 || s_in;
utl_file.put_line( (f_in1,s_in);
end;
end loop;
utl_file.fclose(f_in);
end;
In this case it is reading and writing as it is, but unable to replace the sequence value
Can some one please tell me how to do using replace function
ThanksHi, I have tried this but getting error
step 1: create table test_dept(dno number, dname varchar2(20))
insert into test_dept values(10,'10-Sourcing dept');
insert into test_dept values(20,'20-Audting dept');
insert into test_dept values(30,'30-Computer dept');
select * from test_dept;
DNO DNaME
10 10-Sourcing dept
30 30-Computer dept
20 20-Audting dept
step 2:
create table test_web (name varchar2(60), xml_col xmltype) ;
step 3:
create sequence test1_seq start with 100 increment by 1
step 4:
test.out has the following contents (it is not .xml file) and i dont have <?xml version="1.0" ?> tag at the begining
<File>
<File_Type>Type1</File_Type>
<File_Header_Record>
<file_num>WP10</file_num>
</File_Header_Record>
<Transaction>
<Transaction_Type>TR 1</Transaction_Type>
<Amount>
<Amounts>100</Amounts>
</Amount>
<Depts>
<Dept_Type>Sourcing</Dept_Type>
<Dept>10</Dept>
</Depts>
</Transaction>
<Transaction>
<Transaction_Type>TR 2</Transaction_Type>
<Amount>
<Amounts>200</Amounts>
</Amount>
<Depts>
<Dept_Type>Auditing</Dept_Type>
<Dept>20</Dept>
</Depts>
</Transaction>
<Transaction>
<Transaction_Type>TR 3</Transaction_Type>
<Amount>
<Amounts>300</Amounts>
</Amount>
<Depts>
<Dept_Type>Computer</Dept_Type>
<Dept>30</Dept>
</Depts>
</Transaction>
</File>
step 5:
DECLARE
v_check_file_exist BOOLEAN;
v_file_length NUMBER;
v_block_size NUMBER;
v_file_path VARCHAR2 (100);
v_file_name VARCHAR2 (100);
v_file_type UTL_FILE.FILE_TYPE;
v_str varchar2 (32760);
v_cnt number;
v_seq number;
--check whether file exists and has data in it
BEGIN
v_file_path := '/usr/tmp';
v_file_name := 'test.xml.out';
-- initailise the variables
v_cnt := 0;
UTL_FILE.FGETATTR (v_file_path,
v_file_name,
v_check_file_exist,
v_file_length,
v_block_size);
if v_check_file_exist
then
DBMS_OUTPUT.put_line (' File exists');
IF v_file_length > 0 AND v_block_size > 0
THEN
BEGIN
select test1_seq.nextval into v_seq from dual;
insert into test_web values(v_seq,v_file_name);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
DBMS_OUTPUT.put_line ('No data found '||SQLERRM);
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('others '||SQLERRM);
END;
commit;
ELSE
DBMS_OUTPUT.put_line ('No Data in File');
END IF;
ELSE
DBMS_OUTPUT.put_line (' File Not Available');
END IF;
END;
I am getting below error
File exists
others ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML
processing
LPX-00210: expected '<' instead of 't'
Error at line 1
My requirement is to replace the
1. contents of the file WP10 from <file_num>WP10</file_num>
with sequence value 'WP101' because sequence is starting at 100
2. Replace all Dept tag <Dept>30</Dept> with Dname value from test_dept table
for example
<Dept>10</Dept> should be replaced with <Dept>10-Sourcing dept</Dept>
update the
when i say select * from test_web;
It should contain this row
101 <File>
<File_Type>Type1</File_Type>
<File_Header_Record>
<file_num>WP101</file_num>
</File_Header_Record>
<Transaction>
<Transaction_Type>TR 1</Transaction_Type>
<Amount>
<Amounts>100</Amounts>
</Amount>
<Depts>
<Dept_Type>Sourcing</Dept_Type>
<Dept>10-Sourcing dept</Dept>
</Depts>
</Transaction>
<Transaction>
<Transaction_Type>TR 2</Transaction_Type>
<Amount>
<Amounts>200</Amounts>
</Amount>
<Depts>
<Dept_Type>Auditing</Dept_Type>
<Dept>20-Audting dept</Dept>
</Depts>
</Transaction>
<Transaction>
<Transaction_Type>TR 3</Transaction_Type>
<Amount>
<Amounts>300</Amounts>
</Amount>
<Depts>
<Dept_Type>Computer</Dept_Type>
<Dept>30-Computer dept</Dept>
</Depts>
</Transaction>
</File>
Can you please check
Thanks -
How to replace a string in file
if a file's content is:
aaa 123 456
bbb 341 343
ccc 343 233
now i want to replace 341 with 768
how?
& use which classes? thx!I would suggest
java.io*;
Use a beffered Reader, read the file, and output into another one -
How to replace a string in a text file?
Hi All,
i read one text file and based on that i replaced the old character with the new string but it doesnt works.do any one of you have idea on this?
My Code:
String newPassword=(String) getInputText1().getValue();
String password=(String)getSimNo().getValue();
String sampleText = (String) getMobileNo().getValue();
FileReader fr =new FileReader("c:/newLogin.txt");
BufferedReader br =new BufferedReader(fr);
String record=br.readLine();
while (record !=null)
String[] afterSplit=record.split(":");
for (int p = 0; p < 1; p++) {
String userName=afterSplit[1];
String passWord=afterSplit[3];
if(userText.equals(userName) && password.equals(passWord)) {
passWord.replaceAll(passWord,newPassword);
System.out.println("password: " + password +" changed to : "+ newPassword +" successfully");
record =br.readLine();
sample fiile in the text:
userName:sebas:password:navin
userName:sebas1:password:navin1All readLine does is copy a line of the file into a local variable. Change the copy as you will, the file won't change.
You need to write a new version of the file, with the altered lines. Then, if required, you can delete the original file and rename the new file to the old file name. -
How to replace a string with asterisks? This is related to my previous post
I guess I now need to replace the middle segment of what is retrieved with asterisks.
So, the string in the middle '99999988' should be replaced with '********'. I am basically trying to mask the middle sement string. The length of the original string is not known but the first segment is 6 characters and 3 segment is 4 characters. The middle sement can be anywhere between 5 to 10 characters. In the example below, its 8 characters.
Can I use REPLACE or TRANSALE functions in here ?
select substr('456712999999881234', 1, 6) a,
substr('456712999999881234', 7, length('456712999999881234') - 10) b,
substr('456712999999881234', -4) c
from dual;Thanksif the middle section is entirely numbers then translate(<middle_section>, '1234567890', '**********')
otherwise rpad('*', length(col)-10, '*')
eg:
select substr('456712999999881234', 1, 6) a,
translate(substr('456712999999881234', 7, length('456712999999881234') - 10), '1234567890', '**********') b,
substr('456712999999881234', -4) c
from dual;
A B C
456712 ******** 1234
select substr('456712999999881234', 1, 6) a,
rpad('*', length('456712999999881234')-10, '*') b,
substr('456712999999881234', -4) c
from dual;
A B C
456712 ******** 1234Although thinking about it, I'd just go for the rpad version; requires less processing that using the translate version, and works for more situations (ie. even if there's characters in the middle section, rather than just numbers)
Edited by: Boneist on 16-Jul-2009 16:54 -
How to replace the string of column value with other column value in same table
I have a temp table which contains
Id Name CTC Address Content
1 Ross $200 6th block Dear #Name your CTC is #CTC and your address is #address
2 Jhon $300 1oth cross Dear #Name your CTC is #CTC and your address is #address
Now i want to select content so that it should get replace with the respective columns and final output should come like this
Dear Ross your CTC is 200 and your address is 6th block
Dear Jhon your CTC is 300 and your address is 10th cross
Kindly suggestI think RSingh suggestion is ok ... what do you mean by another way? ...maybe something more generic?
maybe build a table whith the list of col you need to "replace" and dinamically build the replace query ...
declare @colList table(colName varchar(100))
insert into @colList
select 'name'
union all select 'ctc'
union all select 'address'
declare @cmd varchar(2000)
select @cmd='select '+ (select 'replace(' from @colList for xml path('') +' content '+
(select ',''#'+ colName +''', '+ colName +')' from @colList for xml path(''))
+' from YOURTABLENAME '
exec (@cmd)
or your request was different ? -
I have the following string:
String="TVBeginEsternTVEnd
MovieBeginN/AMovieEnd
TVBeginPacificTVEnd
MovieBeginN/AMovieEnd......................"
I need to replace only the contents between TVBegin and TVEnd. The result (If I want the content=Midwest) should look as follow:
String="TVBeginMidwestTVEnd
MovieBeginN/AMovieEnd
TVBeginMidwestTVEnd
MovieBeginN/AMovieEnd......................"
Do you have any suggestions on how to replace the string content?
Thank you very much!Sheshy,
We can tell you how to do small things, one at a time, all day long. You really need to learn how to read the documentation. Go read the documentation for String, StringBuffer. You can figure it out. Really. -
How to replace double quotes with a single quote in a string ?
Hi All:
Can some one tell me how to replace double Quote (") in a string with a single quote (') ? I tried to use REPLACE function, but I couldn;t get it worked.
My example is SELECT REPLACE('STN. "A"', '"', ''') FROM Dual --This one throws an error
Thanks,
Dima.Whether it is maybe not the more comfortable way, I like the quoting capabitlity from 10g :
SQL> SELECT REPLACE('STN. "A"', '"', q'(')') FROM Dual;
REPLACE(
STN. 'A'{code}
Nicoals. -
How to replace multiple occurences of space in a string to a single space?
How to replace multiple occurences of space in a string to a single space?
Hi,
try this code.
data : string1(50) type c,
flag(1) type c,
dummy(50) type c,
i type i,
len type i.
string1 = 'HI READ THIS'.
len = strlen( string1 ).
do len times.
if string1+i(1) = ' '.
flag = 'X'.
else.
if flag = 'X'.
concatenate dummy string1+i(1) into dummy separated by space.
clear flag.
else.
concatenate dummy string1+i(1) into dummy.
endif.
endif.
i = i + 1.
enddo.
write : / string1.
write : / dummy. -
How to search and replace a string in Excel Shape (textbox) using Powershell.
I have been asked to write a PS script to search/replace a string when found in Excel Shapes when they are textboxes. I have seen lots of simplistic PS scripts and even I can do a "foreach" loop through all the Shapes on a Sheet and display the
Name of each Shape. But I have not found a property or method to expose the actual text in a textbox let alone change it.
I have seen vba script that does this as:
Set xWs = Application.ActiveWorkbook.Worksheets(I)
For Each shp In xWs.Shapes
xValue = shp.TextFrame.Characters.Text
shp.TextFrame.Characters.Text = VBA.Replace(xValue, xFindStr, xReplace, 1)
Next
In Powershell, shp.TextFrame.Characters.Text is ignored and returns nothing. It would be nice to know if this is possible in PS and if so, know how to do it and/or get an example to work from. I would have thought that
PS and VB would use the same Excel object model but apparently they do not.
I am using Excel 14.0 and PS 3.
Any suggestions would be appreciated,
MichaelThis didn't work for me. I have the shape object and it shows the textframe property:
PS C:\> $shape | gm
TypeName: System.__ComObject#{00024439-0000-0000-c000-000000000046}
Name MemberType Definition
Apply Method void Apply ()
CanvasCropBottom Method void CanvasCropBottom (float)
SoftEdge Property SoftEdgeFormat SoftEdge () {get}
TextEffect Property TextEffectFormat TextEffect () {get}
TextFrame Property TextFrame TextFrame () {get}
TextFrame2 Property TextFrame2 TextFrame2 () {get}
ThreeD Property ThreeDFormat ThreeD () {get}
But trying to access it gives an error:
PS C:\> $shape.textframe | gm
gm : You must specify an object for the Get-Member cmdlet.
At line:1 char:20
+ $shape.textframe | gm
+ ~~
+ CategoryInfo : CloseError: (:) [Get-Member], InvalidOperationException
+ FullyQualifiedErrorId : NoObjectInGetMember,Microsoft.PowerShell.Commands.GetMemberCommand
PS C:\> $shape.TextFrame.Characters().text="hello"
You cannot call a method on a null-valued expression.
At line:1 char:1
+ $shape.TextFrame.Characters().text="hello"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
I hope this post has helped! -
How to replace a character in a string with blank space.
Hi,
How to replace a character in a string with blank space.
Note:
I have to change string CL_DS_1===========CM01 to CL_DS_1 CM01.
i.e) I have to replace '=' with ' '.
I have already tried with <b>REPLACE ALL OCCURRENCES OF '=' IN temp_fill_string WITH ' '</b>
Its not working.Hi,
Try with this..
call method textedit- >replace_all
exporting
case_sensitive_mode = case_sensitive_mode
replace_string = replace_string
search_string = search_string
whole_word_mode = whole_word_mode
changing
counter = counter
exceptions
error_cntl_call_method = 1
invalid_parameter = 2.
<b>Parameters</b> <b> Description</b> <b> Possible values</b>
case_sensitive_mode Upper-/lowercase false Do not observe (default value)
true Observe
replace_string Text to replace the
occurrences of
SEARCH_STRING
search_string Text to be replaced
whole_word_mode Only replace whole words false Find whole words and
parts of words (default
value)
true Only find whole words
counter Return value specifying how
many times the search string
was replaced
Regards,
Jayaram... -
Hi Experts,
This is not jdeveloper question, but still i am asking, becoz i dont know other blogs......:(
I want to replace one string, i am using StringUtils.replace(originalString,searchString,replacedString) everthing is working fine but if my
originalString:"1,65.0000,65.0000,1,MMMF,Current,SHTC,"
searchString:originalString[3]-- 1
replacedString: testing
so finally string is : :"testing,65.0000,65.0000,testing,MMMF,Current,SHTC," -- its wrong because i thought to change only 3rd element from the array, but the same 1 is there in both positions i tried with
StringUtils.replace(originalString,searchString,replacedString,occurences) when i put occurences as 1 then its changing 0th element.
can any one suggest me how to resolve this issue.
sorry if this question causes inconvinence to any one.
Any inputs could be highly appreciate.
Edited by: user642703 on Feb 29, 2012 9:52 PMhttp://commons.apache.org/ is probably the best place for you to look around (they have a mailing list) - I assume you are using their StringUtils
-
How to find and replace any string between " "
Hi everyone,
Here my sample
String szTest;
szTest = "Yellow banana";
szTest = "Blue monkey";
szTest = "Red mango";
szTest is only needed when it's in testing progress. Now I want to put all of that in the /*comment*/ so the released program won't run those code any more (but still keep szTest so I can use it for future develop testing).
So Here what I want after using the Find and Replace Box:
//String szTest; //Manual
/*szTest = "Yellow banana";*/ //use find and replace
/*szTest = "Blue monkey";*/ //use find and replace
/*szTest = "Red mango";*/ //use find and replace
I think I can do this with Regular expressions or Wildcards. But I don't know how to find and replace any string between " and ".
Find: szTest = " ??Any string?? ";
Replace with: /*szTest = " ??Any string?? ";*/
Thanks for reading.Hi Nathan.j.Smith,
Based on your issue, I suggest you can try the Joel's suggestion check your issue again. In addition, I find a MSDN document about how to use the Regex.Replace Method to match a regular expression pattern with a specified replacement string,
maybe you will get some useful message.
https://msdn.microsoft.com/en-us/library/xwewhkd1(v=vs.110).aspx
If the above suggestion still could not provide you, could you please tell me what language you use to create the program for finding and replace any string using regular expression so that we will find the correct programming develop forum to support this
issue?
Best Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
I really want to know how to replace " in a String with replaceAll()
I want to replace " with \"
Unortunately I am not able to do it with :
xml = xml.replaceAll("\"", "\\\"");Can u please suggest something
thankspublic class Test {
public static void main(String[] args) {
System.out.println("abc>def".replaceAll(">","\"+"));
}Output:
abc"+def -
How to replace the char values into numeric in my string?
Hi Friends,
I would like to Replace the Charecter values with numeric value in my string.
Exp : first in my string I am having the value like this : 'ABCD1234' ( may be any char and num values ), and I want too get it by '99991234'.
I mean How to replace the char values into numeric in my string?
Thanks,
SridharHi Sridhar,
I would like to Replace the Charecter values with numeric value in my string.
Exp : first in my string I am having the value like this : 'ABCD1234' ( may be any char and num values ), and I want too get it by '99991234'.
So, if i understand you correctly, you want to replace all characters in a string with 9 as in the above example, irrespective of position of the character, if so try with the below code.
DATA: l_str TYPE string.
l_str = 'ASKHSIUDNSBDKJSDH124312431243124saasdfsf'.
REPLACE ALL OCCURRENCES OF REGEX '\D' IN l_str WITH '9'.
IF sy-subrc EQ 0.
WRITE: l_str. "Result will be 9999999999999999912431243124312499999999
ENDIF.
Regards,
Chen
Edited by: Chen K V on Jun 13, 2011 12:36 PM
Maybe you are looking for
-
Netbook Mini 110-3830NR How do I create a restore image on a flash drive
I have a HP Mini 110-3830NR Netbook running Windows 7 Starter. I want to create a restore image to original factory state. The user manual recommends that I create a restore disk. It further states that to create a restore image on a USB device, I ne
-
Sony DRU-810A 16x DVD±RW on G4 MDD ?
Hello, I bought myself a Sony DRU-810A 16x DVD±RW since I only got a Combo Drive in my G4 Mirror Door Drives. The guy at Futureshop told me that if my Mac is IDE/ATA compatible, it should work fine even if Sony claims it only works on Wintel PCs. I f
-
Hi, Does anybody knows a way to expand/collapse all folders together (on the left side) in Edge's code panel easily? When having multiple files opened and you have to switch between them, all folders get expanded automatically every single time you s
-
Hello all, I am currently working on an InDesign script (CS3 for now, my employer has been promising CS5 for months but never delivers) which a client presumably will be deploying across many different offices with varying computer skills. In order t
-
Complete folder showing up as sequence.
I have a folder with 113 photos I would like to experiment with in Motion but the whole folder is showing up as a sequence in Motion File Browser. I made a slideshow of the photos in Lightroom but they are still individual photos. If I move one photo