Function to replace/delete specific character(s) in a string
Hi, experienced CVI guys,
Are there some functions shipped with CVI to replace or delete specific characters in a string?
For example, I want to replace all \/|- with an empty string, or to delete them. What can I do? Loops are too complex.
Original string:
Erasing Device...
\|/- \ \ \\|/-\|/ \
Report
07-Sep-2010, 08:04:55
Result I want is
Erasing Device...
Report
07-Sep-2010, 08:04:55
Thanks.
Solved!
Go to Solution.
labc:
How generic do you want to make your filter?
For our discussion, I'll call your series of characters a text spinner. I'm assuming the number of characters in it may vary, but that the pattern is consistent in the respect: the spinner is made up of characters like \ / | -, each followed by the ASCII backspace (char) 8. (That's 8 cast as a character, which is not the same as '8'.) In your sample spinner pattern, every occurrence of the ASCII backspace is preceded by one of the spinner characters. Let's assume that this pattern is constant.
So what I'd do is search through your input string (yes, using a loop) and copy the input string byte by byte to an output string. If you find an ASCII backspace in the input string, skip it, and overwrite the last character in the output string (which is one of the spinner characters) with the next character in the input string.
Yes, you are using a loop, but it's not too complex.
Here's the whole loop, written as a function.
// filterSpinner function to strip the text spinner characters out of a string.
// The text spinner is made up of \ / | - characters separated by (char) 8 (ASCII backspace)
int filterSpinner(char *inputString, char *outputString)
int inputPtr, outputPtr = 0;
// walk though the input string
for (inputPtr = 0; inputPtr < strlen(inputString); inputPtr++, outputPtr++)
// search for the ASCII backspace character that's part of the spinner
if (inputString[inputPtr] == 8)
// if the ASCII backspace is found,
inputPtr++; // increment the inputString pointer to skip the backspace
outputPtr--; // decrement the outputString pointer to overwrite
// the spinner character that preceded the backspace
outputString[outputPtr] = inputString[inputPtr];
outputString[outputPtr] = '\0';
return 0;
You'll also find an attached CVI program which uses it on your sample string.
Attachments:
FilterSpinner1.zip 5 KB
Similar Messages
-
How to replace a specific character acording to position
hi,
tablename
column name
00000111111
so,
i need to update 6 th position only.I am not sure whether there is a direct inbuilt SQL function for this facility. I am giving a method to get this as below:
Logic:
1. Get the substring from first position to the required position minus 1 into the result string
2. Concat the required character to the substring in the above step (result string).
3. Concat the substring from required position plus 1 to the result string
SQL below:
select substr('00000111111',1,6-1) || '1' || substr('00000111111',6+1) from dual -
To delete specific character and digit from a column
Hi Everyone,
THis is the input table, Lot and digits should not be available in the output, but if its lotus then it should be there.
ADDRESS ADDRESS_FORM
LOT 201 JOHN RENSHAW DR
LOT 12 WANNEROO RD
LOT 1 OLD COAST RD
LOTUS CREEK RD
LOT 94 VICTORIA HWY
Out put table should be like this
ADDRESS ADDRESS_FORM
JOHN RENSHAW DR
WANNEROO RD
OLD COAST RD
LOTUS CREEK RD
VICTORIA HWYLike this..?
sql>select * from t;
ADDRESS ADDRESS_FORM
LOT 121 ABCD
LOT 562 XYZB
LOTUS DRTGH
LOT 1 FGET
sql>select decode(trim(address),'LOTUS',address,null) address,address_form
from t;
ADDRESS ADDRESS_FORM
ABCD
XYZB
LOTUS DRTGH
FGET
jeneesh -
Find a specific character in an input string and getting the string after if
Hello,
my requirement is as such, lets say we have an input string ABHISHEK #1234, or BOMBAY 123 #235,
i need to find if the character string has # in it,, if yes pick all the numbers after # .
in the above example, i need output as 1234 and 235
and if any non numeric values after # set a flag
please help me in this.
regards
AbhishekHi Abhishek,
This can be done in BODS using below settings in file format (only if your source is flat file):
Below is the source file data :
abcd#1234,Bombay#23456
By using this file format setting, you should be able to get all the numbers in one column which you can use futher and you can verify this columns data by using "is_valid_int", not null function in BODS.
I think it should give you solution.
Thanks,
Tanvi -
Replacing New Line character in a hexadecimal string in ECC5.0
Hi,
I am trying to create an XML document using ABAP.
I have created one DOM and later used the DOM to get the XML content into an internal table in form of Hexadecimal String. In that internal table(which contains XML in form of hexadecimal content), I want to search for the new line character and replace it by Space.
I have used class CL_XML_DOCUMENT to create such document.
Now, the keyword 'SEARCH' which searches the New Line character, works on the hexadecimal content of the internal table in 46C and I get an XML document. I get the position of the New Line in SY-FDPOS and can do whatever I want. But SEARCH on hexadecimal content is not permitted in ECC 5.0. I get a syntax error when I try to do so. Tried many options but could not succed.
Would apreciate if anyone can help in finding and replacing characters like new line, tab etc in a hexadecimal string.
Thanks.
Can anyoneHi!
When you say hexadecimal string, you mean variable - otherwise string (= character) operations would work?
Then you have to go for hex handling -> do it yourself. Make something like
data: lf type x value '0A',
sp type x value '20',
i type i.
I = 0.
while sy-subrc = 0.
if hex_string+i(1) = lf.
hex_string+i(1) = sp.
endif.
add 1 to i.
endwhile.
Regards,
Christian -
I have thousands of PDFs, mainly text, all fonts are subsets, indexes starting from 1. In page content stream I see character indexes represented as single bytes: binary 1, 2, 3, etc. But, after optimizing files with Acrobat (I use it to save to 1.6 version with compressed object streams etc.) those single bytes become octal strings like \001, \002, ... . Raw stream size is increased by factor 1.5, and after a flate filter there is still 1-2 kB increase for each page. As there are thousands of pages, total (and totally useless) increase is considerable and doesn't go well with my goal of creating as small package as possible.
Can this behavior be prevented (with something like registry setting)?what are you calling getBytes() on?he's calling getBytes() on his String object.
@ puneet_k,
I don't have a solution but note that on Unix-like systems a newline is a single byte 0x0a and on DOS-like systems (Windows) it is a sequence of bytes 0x0d and 0x0a.
Some text editors handle both.
I'm not sure but I think on Unix,
new String("\n").getBytes() equals new byte[] { 0x0a }
and on DOS
new String("\n").getBytes() equals new byte[] { 0x0d, 0x0a } -
String function to count total number of a specific character.
Gurus,
I've been trying to use INSTR to decipher a string to count the number of pipes in each string. Anyone have a simple SQL which shows how to use a string function to return a count of a specific character?
Thanks
-ScottHi, Scott,
To see how many '|' characters are in txt, you can see how much txt shrinks when you remove the '|'s.
LENGTH (txt) - NVL ( LENGTH ( TRANSLATE ( txt
, 'x|'
, 'x'
, 0
)The expression above works in any version of Oracle.
Starting in Oracle 11, you can also use REGEXP_COUNT:
REGEXP_COUNT (txt, '\|')'|' is a special symbol in regular expressions, so it has to be "escaped" ('\|') to indicate the pipe character. -
How to select a substring in oracle up to a more than one specific character
How to select a substring in oracle up to a more than one specific character
for ex : 121.051^NP: FAMILY PRACTICE ( trim the values before ^ )
121.051^*NP: FAMILY PRACTICE (trim the value before *).
with below function I can only get rid of ^ , I want both the specific characters ^ and ^* to be removed at the same time.
SUBSTR(p.phys_sub_grp_2_desc,INSTR(p.phys_sub_grp_2_desc, '^') +1)Another option is to boldly replace 'em:
SQL> with t as (
2 select '121.051^NP: FAMILY PRACTICE' str from dual union
3 select '121.051^*NP: FAMILY PRACTICE' from dual
4 )
5 --
6 -- actuel query:
7 --
8 select substr( replace(str, '*')
9 , instr(replace(str, '*'), '^')+1
10 ) str
11 from t;
STR
NP: FAMILY PRACTICE
NP: FAMILY PRACTICE
2 rows selected. -
Is there any BAPI or function module to delete entries from a table (VBAK)
Hi Everybody,
this is my first thread in SDN...
my problem follows...
A report is be created that selects all sales orders created by e-Sales that are more than 20 minutes old and still have a delivery block:
tables:
VBAK sales document: header data
selection fields:
VBAK-LIFSK ≠ <BLANK>
VBAK-ERNAM = userID used by e-Sales / IVE
(EP-BATCH / EAI-BATCH)
VBAK-ERDAT <= Current system Date
VBAK-ERZET <= Current system Time - 20 minutes
These orders should be deleted from SAP system.
This report should be scheduled to run regularly every 10 minutes.
my doubt : is ther any BAPI or Function module to delete entries from a standard table...if no what is the way to delete the enteries from a std table...
best replies will be rewarded....
regards
ReddyHi Vasanth ,
thanks for your reply.
i tried in the same manner what u mentioned.
but how to pass only one parameter to the functionmodule..
here in this case we have to pass only update flag as 'D'..
i did the same it giving dump..
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_DYN_CALL_ILLEGAL_TYPE', was
not caught and
therefore caused a runtime error.
The reason for the exception is:
The call to the function module "BAPI_SALESORDER_CHANGE" is incorrect:
In the function module interface, you can specify only
fields of a specific type and length under "ORDER_HEADER_INX".
Although the currently specified field
"INT_ORDER_HEADER_INX" is the correct type, its length is incorrect.
my pgm :
*& Report YNEW_ORDER_DELETION
REPORT ynew_order_deletion.
TABLES:vbak.
PARAMETERS:
p_lifsk LIKE vbak-lifsk DEFAULT '02'.
SELECT-OPTIONS:
s_lifsk FOR vbak-lifsk DEFAULT '10',
s_ernam FOR vbak-ernam,
s_erdat FOR vbak-erdat,"DEFAULT sy-datum.
s_erzet FOR sy-uzeit.
*PARAMETERS:
p_erzet LIKE sy-uzeit.
s_erdat like vbak-erdat,
s_erzet like vbak-erzet.
DATA:
BEGIN OF int_final OCCURS 0,
w_vbeln TYPE vbak-vbeln,
END OF int_final.
DATA:
int_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: int_order_header_inx LIKE bapisditmx OCCURS 0 WITH HEADER LINE.
DATA:
wf_time TYPE sy-uzeit.
INITIALIZATION.
s_ernam-low = 'KULKARMA'.
s_ernam-sign = 'I'.
s_ernam-option = 'EQ'.
APPEND s_ernam.
s_ernam-low = 'EAI-BATCH'.
s_ernam-sign = 'I'.
s_ernam-option = 'EQ'.
APPEND s_ernam.
wf_time = sy-uzeit - 1200.
p_erzet = sy-uzeit - 1200.
p_erzet-low = wf_time.
APPEND s_erzet.
int_order_header_inx-updateflag = 'D'.
APPEND int_order_header_inx.
START-OF-SELECTION.
SELECT vbeln FROM vbak
INTO TABLE int_final
WHERE lifsk EQ p_lifsk
AND ernam IN s_ernam
AND erdat IN s_erdat
AND erzet IN s_erzet.
IF sy-subrc = 0.
LOOP AT int_final.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = int_final-w_vbeln
ORDER_HEADER_IN =
order_header_inx = int_order_header_inx
SIMULATION =
BEHAVE_WHEN_ERROR = ' '
INT_NUMBER_ASSIGNMENT = ' '
LOGIC_SWITCH =
NO_STATUS_BUF_INIT = ' '
TABLES
return = int_return
ORDER_ITEM_IN =
ORDER_ITEM_INX =
PARTNERS =
PARTNERCHANGES =
PARTNERADDRESSES =
ORDER_CFGS_REF =
ORDER_CFGS_INST =
ORDER_CFGS_PART_OF =
ORDER_CFGS_VALUE =
ORDER_CFGS_BLOB =
ORDER_CFGS_VK =
ORDER_CFGS_REFINST =
SCHEDULE_LINES =
SCHEDULE_LINESX =
ORDER_TEXT =
ORDER_KEYS =
CONDITIONS_IN =
CONDITIONS_INX =
EXTENSIONIN =
ENDLOOP.
LOOP AT int_return.
WRITE:/ int_return-type,
int_return-id,
int_return-number,
int_return-message.
ENDLOOP.
ENDIF.
please help me ..its a very urgent issue to be solved...
am waiting for ur reply...
regards
gangareddy -
Function Module to Delete ODS Data based on Request
Hi All,
Is there any specific function module to delete ODS data based on Request.
I found the program RS_DEL_ODS_1 which is using the FM RSAR_ODS_API_DEL.
But this FM is deleting the request at PSA level.
Is there any alternate FM?Or is there any ABAP Program or so?Hi,
Deletion of specific request is not perimitted for ODS objects. You can delete the most recent request, but if you delete any previous requests, all the requests up to that request will also be deleted.
You can do it by write an ABAP program to identify the specific requests to be deleted for ODS.
Regards
CSM Reddy -
Search and replace, everey second character?
I'm making a VI that is communicating with an external device through a protocol built up of frames. I have made a couple of subVIs that put these frames together as hexadecimal strings that are then converted into numbers and passed on to the device. The protocol uses an escape character in order to avoid sending an BOF or EOF constant at the wrong time. I've made a subVI that is supposed to do this using the Serch and Replace function. At first it seems rather elegant, but it has a fatal flaw, if one of the characters it is supposed to hide is written across the edge of a byte, it will still be replaced.
Example:
11 01 00 EC 0D EA 05 08
is replaced by
11 01 00 E7 DE 0D EA 05 08
C0, C1, 7D are the characters to be replaced, 7D is the escape character.
Now I wonder, is it possible to make the search and replace function search only every second character in a string?
Solved!
Go to Solution.
Attachments:
Insert_Escape_Characters.vi 10 KBHi,
I'm not sure to understand your problem, but I propose this solution !
Hope it helps you.
Best regards,
Vincent
Message Edité par ramses64 le 02-20-2009 03:57 AM
V-F
Attachments:
replace.PNG 17 KB -
Deleting a character at a time from a textarea
I am designing a mobile phone simulation, where the user creates a message from a keypad, to the text area, there is a back button that does two things:
1. Deletes a character at a time
2. Moves back through text
How do i delete a character at a time //
I thought about doing a count of the text in the text area then use delteCharAt() and give the position as count - 1 and the value as "" would this work
Thank youI ran into this situation before. Try this for the backspace:
textBox.setText(textBox.getText().substring(0,textBox.getText().length()));
...Woah... I think that works, it just looks kinda complicated. For textBox, replace it with the name of your JTextField
As for the going back through text, use an arraylist (or vector or whatever your choice for a collection) and when they click like a "back button" then it would do a textBox.setText(collection.get(current - 1);
(JTextField textBox, Collection collection, int current)
Hope this helps! -
Writing plsql function to find out repeating character in a string
I need to write one pl sql function to compare 2 consecutive character in a word that they are same or not, if same return false otherwise return true. could any one help me on this
what i have written pasting here code or make me correct
CREATE OR REPLACE FUNCTION validate_password (v_string IN VARCHAR2)
RETURN BOOLEAN
IS
v_number NUMBER (3) := 1;
i_length NUMBER (3);
BEGIN
SELECT LENGTH (v_string) INTO i_length FROM DUAL;
IF (i_length > 0)
THEN
FOR v_number IN v_number .. i_length
LOOP
substring (v_string, v_number, 1) :=
substring (v_string, v_number + 1, 1);
v_number := v_number + 1;
END LOOP;
END IF;
RETURN v_string;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('message');
END;
Thanks in advance.no need to SELECT FROM DUAL;
How do I ask a question on the forums?
SQL and PL/SQL FAQ
scroll down to #9 to see how to use tags as below
[code]
CREATE OR replace FUNCTION Validate_password (v_string IN VARCHAR2)
RETURN BOOLEAN
IS
v_number NUMBER (3) := 1;
i_length NUMBER (3);
BEGIN
i_length := Length (v_string) ;
IF ( i_length > 0 ) THEN
FOR v_number IN v_number .. i_length LOOP
Substring (v_string, v_number, 1) :=
Substring (v_string, v_number + 1, 1)
v_number := v_number + 1;
END LOOP;
END IF;
RETURN v_string;
EXCEPTION
WHEN OTHERS THEN
dbms_output.Put_line ('message');
END;
[/code] -
Job to delete specific Error Messages
Experts,
We are facing the need to create a job which deletes specific error messages (specific sender service and interface combination, plus specific error category). Which are the best options to achieve this?
I guess this can be done in the Deletion Procedure but in the Threads I found there wasn't a detailed description. It there any documentation for that?
Your input is appreciated.
Cheers,
MathiasThanks for this link.
I am afraid the standard function does not offer what we are looking for.
To put this into an example:
A message from Sender Service A and Sender Interface B fails in the message processing with a specific error category e.g. MAPPING I EXCEPTION_DURING_EXECUTE
This error is classified as a known error and should be deleted from the Database (Monitoring Screen).
Can this be achieved without an ABAP development? -
Recover deleted specifications
Hi all!
While working with transaction CGE2, a user deleted by mistake a specification. He did that, either by right clicking on the Spec number or by selecting the specification in the hit list and then select the "Delete" option from the Specification menu. I´m not sure which option he used.
Is there a way to recover deleted specifications? I´m aware of the deletion indicator in table ESTRH but, how can I delete that indicator? Is there any standard function that can modify that table? Should I delete another deletion indicator that I´m missing from another related table?
Thank you!
Eugeniasorry to reply this question at this really late time but hope everything goes fine, especially in this special holiday season! Cheers in advance
Well, iPhone use quite different storage media which means once you deleted stuff (such as photos, videos etc) off it, it's just gone and can't be recovered with general free Mac data recovery software like TestDisk or PhotoRec.
But there might still be some chances for you to recover those Videos. And ALL in ALl depends on whether you ever sync your iPhones via iTunes on your Mac machine (before you deleted the videos). If yes, then probably you can use this program Data Recovery for iTunes to restore your videos on Mac machine (without connecting your iPhone).
Next time, remember to back up everyting regularly in case any similar suffering happen.
Hope this helps.
Maybe you are looking for
-
Safari 5.0.6 and hotmail clash
Safari 5.0.6 is giving me 'bad server certificates' on hotmail / live.com servers starting with gfx (from Activities). Microsoft are advising to change to a new browser like Chrome or Firefox (not compatible with this OS). Where is the discussion on
-
About Java mapping and java proxy
Hi Iam new to Xi and basically iam an ABAPER.When iam dooing mappinps or proxies i cant able to understand the java pari cant (javamapping and java proxies) .I need some notes on java mapping and java proxy which is easy to do.And why do we use this
-
Post-Processing of requested failed
We are running 11i.XDO.H(3263588) 1)Post processing of one of our XML Publisher enabled report failed with the following error: Post-processing of request 3165233 failed at 12-MAY-2006 14:16:14 with the error message: One or more post-processing acti
-
IMovie, presenza della versione 9.0.9 contestuale alla 10.0.2
Non è un problema di iMovie, ma la presenza della versione 9.0.9 contestuale alla 10.0.2, cosa devo fare, per non fare danni.grazie
-
Is iPhoto included with computer?
I purchased a Mac Pro and it has iTunes and iMovie, but doesn't appear to have iPhoto. What am I missing? Do I have to buy it separately?