Problem of string manipulation
HelloI have a problem with string manipulation. I need to compare the character with his next character.
as an example consider the string as "fat".
'b' must be compared with 'o'.
"o" by 'l' and so on.
I used below the code snippet.
for (int i = 0; i < s.length (); i ++)
{
int j = i + 1;
If (s.charAt (i) == s.charAt (j))
{
status = false;
}
on the other
{
status = true;
}
}
But I get an error message. Help, please. Thanks in advance.
Published by: Vinayjgeorge on June 1, 2011 12:26 AM
Published by: Vinayjgeorge on June 1, 2011 12:39 AM
(1) for the validation of code, use the code tags so that it will be readable: http://forums.oracle.com/forums/ann.jspa?annID=1429
(2) "I get an error" means nothing. Do you think that there is only a single possible error that may appear in the Java code and the only possible thing that can? If this isn't the case - in other words, if you don't know that there are different errors and causes - so why you thought that simply say "I get an error" without any details would be sufficient to describe the error? You must copy and paste the exact, complete error message, if you want to communicate clearly what problem you encounter so that people can help you.
Please put a little more thought in upcoming posts.
That said, in this case, it is easy to see an error you will get. Loop tells you ' for each character in the string, compare this character with the next. " You can see why it does not work? When you get to the last character, the comparing it to that is not possible, because there is not a next. You say "for all characters except for the last, compare it to the following."
Once correct you that, you always seem to have a logic error. You are just blindly setting status to each character, so when you're done, just status will contain everything that produced the last comparison. It might go back between true and false to each character, but the only one that will count will be the last.
Edited by: jverd May 31, 2011 12:06
Tags: Java
Similar Questions
-
The question
I need to segment data on a large number of Postal Codes, usually about 400 to 600 at the same time. It is that our postcode field includes the last four digits in some cases, for example 92101-1957. When you use the Contact filter 'Value In A' I'm not able to do this 92101 *, 92102 * and of course I can't account for any combination of four numbers that might appear.
The Solution - in theory
The solution I came up with that is to create a new field of Contact in Eloqua 'Segmentation Zip Code' copy of the 5 digits of the postal Code field and execute segmentation using this new field.
The Solution - Cloud Connector
String Manipulation cloud connector must be able to perform this action - copy on the first 5 digits of the zip in the zip segment field field.
When I'm stuck - via cloud connector
I can't figure out how to write the syntax for expressions to search and replace. I have read the instructions of syntax and am still unable to establish exactly what I enter in the "regex to find: ' and the ' Regular Expressions to replace:
Does anyone have expierence with an Expression syntax that might help train these expressions?
Any ideas on other ways to address the problem would be too great.
Thank you
Louis
Hi Louis,.
Okay, I think I might know how to do it now but don't have access to Eloqua for the moment, so I'm kind of make this Store, but try below.
Use the regex below in the "Regex for find" and let the "Regex to replace white": "."
-(.*)$
This will be after the hyphen and the replacement string will be empty, so I hope you should be left with just the first five digits that you can map to a new field.
Let me know how you get on, I might be able to test myself so tomorrow so I'll see if I can make it work.
Chris
-
comma delimeted string manipulation
Three possibilities of decoding where it goes. BB SDK 5. Data GPS are stored in a vector of singleton in the form of a string. Essentially the string looks like this: value1, value2, value3, value4, Value5, Value6,
There can be more than 1 string in the singleton at some point I want to get a timer task in another thread is so to check each string, divide the data into other variables so that I can create a message that will be sent via an http connection. Bit, I'm glued to the minute tire data back to specific variables... I try to use a cup of the version of http://supportforums.blackberry.com/t5/Java-Development/String-Manipulation-split-replace-replaceAll... because I already know what will be the delimiter and also the amount of the values contained in the string, but I must be missing something here. The code that I need to check the vector and to try and do things variable is therefore:
for (int i = 0; i)< instance.vector.size();="">
{
String elementReturnString = instance.vector.elementAt (i) m:System.NET.SocketAddress.ToString ();
String strDelimeter = "";
String results [] = new String [6];
int iOccurrences = 0;
int iIndexOfInnerString = 0;
int iIndexOfDelimiter = 0;
int iCounter = 0;
System.out.println ("string delimiter =" + strDelimeter); It appears,
While ((iIndexOfDelimiter = elementReturnString.indexOf (strDelimiter, iIndexOfInnerString))! = - 1).
{
results [iCounter] = elementReturnString.substring (iIndexOfInnerString, iIndexOfDelimiter);
iIndexOfInnerString = iIndexOfDelimiter + strDelimiter.length ();
iCounter += 1;
}
System.out.println ("# latitude =" + results [0]); It's never farLat string results = (0);
Lon string = results [1];
Line speed = results [2];
etc etc etc.}
He bombed in the debugger with a number of errors with the first course cannot find symbol on the strDelimeter on while the statement variable. It fails every other time its use, but it displays a comma in the system.out statement. He also says that iIndexOfInnerString = iIndexOfDelimiter + strDelimiter.length (); Cannot be applied to strDelimeter.length.
..... Any ideas please? I tested that he can see in the vector information ok.
You wrote your variable strDelimeter and strDelimiter (note the an i e).
-
Problem with string to Int conversion
Dear friends,
Problem with string to Int conversion
I'll have a column where most of the values is digital. Only 4 values are not numeric.
I have replaced the non-numeric values to numeric in order to maintain the data type.
Grade.Grade DEAL WHEN "E4" THEN "24' WHEN 'E3' THEN '23' WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' Grade.Grade OTHER END"
This is the result as inactive
Grade
_0_
_1_
_10_
_11_
_12_
_13_
_14_
15
_16_
_17_
_18_
_19_
_2_
_20_
_21_
_22_
_23_
_24_
_3_
_4_
_5_
_6_
_7_
_8_
_9_
Discount
- - -
Now I want to convert this value in digital and do some math
So I changed the formula as below
Cast (CASE Grade.Grade WHEN "E4" THEN "24' WHEN 'E3' THEN '23' WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' Grade.Grade END as an INT. ELSE")
Now I get the following error
View display error
Driver Odbc _ returned an error (SQLExecDirectW). _
Error details
Error codes: OPR4ONWY:U9IM8TAC:OI2DL65P
_State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 17001] Oracle error code: 1722, message: ORA-01722: invalid number in the OIC calling OCIStmtFetch. [nQSError: 17012] In bulk fetch failed. _ (HY000)
SQL issued: SELECT cast (CASE Grade.Grade WHEN "E4" THEN "24' WHEN 'E3' THEN '23' WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' Grade.Grade END as an int. ELSE") seen'Human Capital' 0 - Costing Manpower WHERE LENGTH (Grade.Grade CASE WHEN 'E1' THEN '20' WHEN 'E2' THEN '21' WHEN 'E3' THEN '22' WHEN "E4" THEN "23 ' ELSE Grade.Grade END) > 0 ORDER BY saw_0_
Discount
Could someone help me
Concerning
Mustafa
Published by: Musnet on June 29, 2010 05:42
Published by: Musnet on June 29, 2010 06:48Are you sure you don't have another non-digital value in your column. I want to get this filter temporarily just to check if your plaster works or not. If it works, then you can remove this filter.
-
LabVIEW 8.5 problems using strings with MATLAB Script node
I am having some problems that seem to be a bug that I can not understand how to solve using strings in the MATLAB script node.
I have two subVIs that make some calculations and both include a variable called "errortext" is a string. The two subVIs do their calculations using the MATLAB script node, so all the outputs are defined in the script node.
The first sub - VI outputs that string and a number. The string is sent to an indicator on the front panel. The number is sent to the second Subvi which performs some calculations more and then returns another string of the same name to an indicator on the front panel. This second string is different from the first (error different two messages should appear).
I did have problems with this in the past until this morning. This morning, it seems that two of these channels are now somehow mystically connected to each other. The second string repeat that what the first channel said despite the fact that the first string is not be linked to the Subvi where lives the second string. The only link between the two is a calculated value of double which went from #1 to the Subvi #2 Subvi.
I tried many things: I tried to rename the strings so that they do not have the same name. Initially, he would not let me and gave me an error saying that the renowned string was a undefined variable (which is ridiculous). After removing and replacing things, I finally managed to do so I would change the name, but now it displays nothing at all and even more I think it might still display a completely different another string in my code!
I also tried to remove the channel indicator and replace it. Yet once, it wouldn't let me initially. I would like to highlight, press DELETE and nothing. Finally after replacing all the subVIs with them, I was able to remove the flags, but this did not help the problem.
Any idea for these problems pecular is greatly appreciated!
I totally understand what you did, you were talking about variables in your fist post, and it was not clear if you were referring to a variable you have defined in the Matlab code, or you try to call a variable indicator/control, where is often seen on this forum (and who isn't). That said, the crux of The Matlab Script communicates with Matlab via ActiveX, and when you use a command window opens small. This is the workspace of Matlab environment. A variable that you define in a Matlab Script node will be visible in the other, even if it's in another VI (see attached for an example, figure). This is because the script nodes are running in the same environment space. It seems to me that if this is what is happening.
-
Problem with string writing series
I'm using labview to send commands to a device using the serial port com1. Using the example VI "Base series in reading and writing", I can communicate with my hardware very well, can write and can read. the problem comes when I want to edit the VI by using my own string instead of the string provided in the example. When I create a string constant with the exact text that was in the example string box, I can not write my material.
I don't understand why this wont work. Is there something special about the example of the VI text 'string to write' box that I don't know?
Help, please
Thank you
I know what you mean and it does not work like that. For some reason if I use a string with \r\n constant it still does not work.
Anyway, I solved the problem in a roundabout way. The command I sent you is a word but both parties; first part, second part number. I want to create a loop when the number changes. I was able to do this by combining three channels, the first is a copy of the example string, the middle is my number converted to string, the third is a different copy of the string of examples. Now it works and I can with my life
-
PROBLEM character string of ESC in a
I can't send this message on the forum of the French comm...
Hi all
I (still) have a problem and I need a little help please.
Plug-in a Heidenhain ND287 counter and having not found driver to use it, I have to create my own functions. One that allows to ask the measured value pose worries...
USB communication.
I send correctly the order and receives good response. However, this last has 'characters' escape (visible as a square from a string indicator) that I can't manage. Indeed, there may be 2 or 3 before the numeric value, and I need to isolate this last pour is able to be read (if I read 0).
I tried various methods but without success...
Has anyone an idea?
Hello
Thanks for the screenshot. Are you sure that the returned carractère is "ESC" with code 1 b? Maybe look at the hex code of the returned string and vevifiez that the first character has the code 1 b
Pour do this, use the range of problems of function 'chain in byte array' functions: Programming::Numeric:Conversion and the 'number of hexadecimal string' function the functions palette: programming:tring:tring/number Conversion
The actually if "character mystery has not pay code hexadecimal 0x1B, it is normal that it is not filtered."
Kind regards
-
SystemPrompt result text string manipulation does not: what am I doing wrong?
I'm trying to manipulate a "collar", I get a SystemPrompt. Here is my code:
SystemPrompt { id: prompt title: qsTr("prompt") inputField.maximumLength: 16 inputField.defaultText: prompt inputField.emptyText: "prompt" inputField.inputMode: SystemUiInputMode.NumericKeypad // eNum: Default = 0, Email = 1, Password = 2, Phone = 3, Pin = 4, // Url = 5, Symbols = 6, NumericKeypad = 7, NumbersAndPunctuation = 8 onFinished: { if (result == SystemUiResult.ConfirmButtonSelection) { result = inputFieldTextEntry() //result = result.mid(0,4) + " " + result.mid(4,4) + " " + result.mid(8,4) + " " + result.mid(12,4) //result = inputFieldTextEntry.mid(0,4) + " " + inputFieldTextEntry.mid(4,4) + " " + inputFieldTextEntry.mid(8,4) + " " + inputFieldTextEntry.mid(12,4) labelPrompt.text = result //labelPrompt.text = result.mid(0,4) + " " + result.mid(4,4) + " " + result.mid(8,4) + " " + result.mid(12,4) toast.body = "prompt result: " + result //toast.body = "result: " + result+ result.size // this causes the toast result.size value to be "undefined" toast.show() } // if } // onFinished } // SystemPrompt [...] attachedObjects: [ SystemToast { id: toast onFinished: { } } ]
I certainly made the generic object compared to my exact code names. My problem is this: none of all the commented code works. What I'm trying to do is to inject a space character between each 4 numbers entered via the SystemPrompt. If I activate one of the commented lines, the soft seems to go out the onFinished SO without finishing (evidenced by the absence of toast).
I have tried to type casting toString() here and there, but that shouldn't be necessary since QML handles type casting automatically. I tried to add a debug string size value to my bread which gives a result 'undefined' for result.size
Can someone indicate an error of my ways here?
Not subst... There
cardNumber = cardNumberTemp.substr(0, 4) + " " + cardNumberTemp.substr(4, 4) + " " + cardNumberTemp.substr(8, 4) + " " + cardNumberTemp.substr(12, 4)
-
Problem with string comparison
I have a web service that I use two compares two strings, one from the service web xml of my application.
XML retrieves a string when I compare it like this
If (xmlVersion == 'true') {}
}
It never enter the if condition when I print the value I get from the service I think like this (real).
So, what's the problem here?
The way you wrote the comparison. you simply compare the addresses of the two strings.
Try this instead:
xmlVersion.equals ("true").
In fact, you might want to consider getting these out to the back to avoid would be Null Pointer Exceptions, like this:
If (true".equals (xmlVersion)) {" "}
}
-
Starting with the data for this example:
I am trying to find a way to get the first section of chain BEFORE and also the little after that, including 2 letter string - for example I would like to extract:GET sampledata WITH sampledata AS (SELECT 'THIS Information Collection GL Enquiry User' resp FROM DUAL UNION ALL SELECT 'THIS Information Collection PO Web Requisitioner and Receiver' FROM DUAL UNION ALL SELECT 'THIS Asset Management Team GL Enquiry User' FROM DUAL UNION ALL SELECT 'THIS Asset Management Team PO Web Requisitioner and Receiver' FROM DUAL UNION ALL SELECT 'THIS Collections GL Enquiry User' FROM DUAL UNION ALL SELECT 'THIS Collections PO Web Requisitioner and Receiver' FROM DUAL) SELECT * FROM sampledata;
However, I am rather stuck - I think I will need to use a combination of INSTR() and SUBSTR(), but the problem is that the 2 letter string appears after a variable number of words, so there is no ordinary way to check where to appear the 2 letters - more the 2 letter string will be different each time - not only GL and PO as above , but one range of others, for example, AR, AP, etc. OM.BEFORE | AFTER -------------------------------------------------------------------------------- THIS Information Collection | GL Enquiry User THIS Information Collection | PO Web Requisitioner and Receiver THIS Asset Management Team | GL Enquiry User THIS Asset Management Team | PO Web Requisitioner and Receiver THIS Collections | GL Enquiry User THIS Collections | PO Web Requisitioner and Receiver
Any advice much appreciated.
Thank you!Like this?
SQL> ed Wrote file afiedt.buf 1 WITH sampledata AS 2 (SELECT 'THIS Information Collection GL Enquiry User' resp FROM DUAL UNION ALL 3 SELECT 'THIS Information Collection PO Web Requisitioner and Receiver' FROM DUAL UNION ALL 4 SELECT 'THIS Asset Management Team GL Enquiry User' FROM DUAL UNION ALL 5 SELECT 'THIS Asset Management Team PO Web Requisitioner and Receiver' FROM DUAL UNION ALL 6 SELECT 'THIS Collections GL Enquiry User' FROM DUAL UNION ALL 7 SELECT 'THIS Collections PO Web Requisitioner and Receiver' FROM DUAL) 8 SELECT regexp_replace(resp,'^(.*) [^ ]{2} .*$','\1') as resp1 9 ,regexp_replace(resp,'^.* ([^ ]{2} .*)$','\1') as resp2 10* FROM sampledata SQL> / RESP1 RESP2 ---------------------------------------- ---------------------------------------- THIS Information Collection GL Enquiry User THIS Information Collection PO Web Requisitioner and Receiver THIS Asset Management Team GL Enquiry User THIS Asset Management Team PO Web Requisitioner and Receiver THIS Collections GL Enquiry User THIS Collections PO Web Requisitioner and Receiver 6 rows selected.
-
I create a button which when you click on a corresponding text of reference field in an existing text field. Here is the code:
myVariable1 = "my text";
myVariable2 = 'text ';
for (i = 0; i < = 8; i ++) {}
This ["circle" + i] .uniqueID = i;
This ["circle" + i] .onRelease = function() {}
test_str = myVariable + this.uniqueID
};
}If you click the button whenever circle1 myVariable1 needs to load in the text field Dynamics test_str. When you click circle2 myVariable2 should load and so on. The problem is that I get a is not a numeric response (NaN) in the text field. I know it has something to do with the combination of a string with a number, but can not solve this problem. I tried toString() and other pieces of code, but it does not work. Thanks in advance.
Three things:
1) there is a minor tangle of 'this' in the onRelease function. Inside this function, 'this' refers to the object of the circle, but your variable lies outside in the main timeline, so...
myTextField.text = _root ["myVariable" + String (this.uniqueID)];
(2) your loop starts at 0, but your variables start at 1. Don't forget to make them accept, otherwise your code looking for myVariable0 that is not
(3) when you declare a variable, declare a variable...
myVariable1 = work «»
should be...
var myVariable1 = work «;»
-
SQL and the Q Q string manipulation
I'm trying to find out if I can use the manipulation of SQL strings in a Q Q. Here is an example of what I'm trying to do:
< cfquery dbtype = "query" name = "supportstatements_order" >
Select *, right (SupportStatements.Name, 12) as short_name
Of SupportStatements
Order by name
< / cfquery >
I get an error in CF I have an incorrect select statement.
Is it possible to do with Q of Q?
Thank you very much.
Anyone know if I could use queryaddcolumn in this situation?
Gather your themes led to the next suggestion
Erratum edit: data type correct varchar added
-
fract/exp to problem number string.
Hi ppl,
I have a very simple question. I want to convert string 5.3696075E - 4 for the number. in my program, it gives me only 5.
Please, help me.
Your operating system is probably to use a comma instead of a period as the decimal separator.
The Fract/Exp string to number function has an entry at the top Optional Boolean. The default value is True, revealing LabVIEW use parameter system OS for the separator.
'Use decimal system (T)' set to false, and that should allow you to convert the string correctly...
-
I'm working my way with the homework, and I was searching the Internet about the concatening of the word into two substrings. However, how can I say it so that he knows what he he always separates 50%? Which means half of the word goes into 1 indicator and the other half goes in the indicator 2. For now, I have to manually set the number, but it won't work if I type in another word, of course.
PackersFan wrote:
As said altenbach, note that it worked well with a string with a length of. If the length is odd, you will need to turn and have uneven substrings.
You don't want to use the simple fracture operation, because it will give an orange output. Use the quotient and remainder keep permanently blue.
- To round down, use the output of the floor
- To complete, add the rest to the floor exit (if the division by a number greater than two, apply the sign function to the rest first)
-
String manipulation &; table
Hello
Maybe someone can give some advice. I read the data on the temperature of a Hydra of 2620a Fluke. I went to work, one every few seconds the temperature reading is fast enough. The moat returns a string containing a number of temperatures for each analysis. Each test returns a string, something like + 0023.7E + 0, + 0025.6E + 0, + 0023.8E + 0...
9 sensors are measured. For each channel, I can parse the string to a numeric string, convert it to a number and add this number to a table.
Say that temperatures are 1,2,3,4,5. I find myself with a table 1 d, 1 2 3 4 5 1 2 3 4 5 12 3 4 5 1 2 3 4 5... write this to an LVM file results in 1 column with all these numbers.
What I need is a number for each scan line, as follows (an additional column would be times)
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
I'm having a brain freeze and I just cannot find a way to do it.
Also, I need to display these temperatures in a graph. If I have the temperatures in a picture, I can manipulate them and do the required calculations.
If some has a suggestions that would be great. I'm using Labview 2012.
Attached, is the part that needs to do this. 1,2,3,4,5 chain would be the release of the moat and would read up to the stop.
Thanks in advance
Arne
And if you also want their graph, simply send them a chart:
Maybe you are looking for
-
Hello. My question is:How can I install Win XP on my laptop?I'm looking for drivers on my Satellite A660-1 for Win XP, but I can't find anything :( PLS, help.
-
Windows update-reception 80240016 error code when trying to update.
80240016 error messages
-
Computer says Runtime Engine installer does not meet the system requirements.
I am running mac OS 10.4.11 on an iBook G4 (ppc). I try to install the LV 8.6.1 runtime in order to use editing utilities were created by the user with the scripts of LV. I have LV 8.5 (with installed scripts). "You can not install a Labview 8.6.1 ru
-
Updated mapping of user names in C:\Users Control Panel user accounts.
HelloWindows Vista Edition Home Premium SP2. I'm trying to match user accounts in Control Panel with those listed in C:\Users\(name-of-user).I need to do this on a new computer, so I can network with existing computers.On my 3 computers existing, som
-
ASA VPN network access internal
We have ASA5510s and I set up a VPN SSL using AnyConnect... The VPN address pool is 10.10.10.0/24 and our internal network is 10.10.20..0/24. After the connection successful, using LDAP. the customer receives an address 10.10.10.0/24 from the pool, b