I have a string with markup in it which I need to find using Java.
eg.
string = abc<B>def</B>ghi<B>j</B>kl
desired output..
segment [n] = start, end
segment [1] = 4, 6
segment [2] = 10, 10
|
I have the following code snippet where some strings are initialized in the if block:
String serialmask = request.getParameter( "serialmask");
String serialincrement = request.getParameter( "serialincrement");
if (serialmask == "1") {
String ...
|
We have a huge code base and we suspect that there are quite a few "+" based string concats in the code that might benefit from the use of StringBuilder/StringBuffer. Is ... |
Is there a nice way to extract tokens that start with a pre-defined string and end with a pre-defined string?
For example, let's say the starting string is "[" and the ending ... |
I'm looking for the best approach for string find and replace in Java.
This is a sentence: "My name is Milan, people know me as Milan Vasic".
I want to replace the ... |
I'm writing a program that asks the user for their birthdate and then calculates that birthdate on different planets. I am not suppose to assume how the birthdate is to be ... |
Here's the relevant code:
public static String[] runTeams (String CPUcolor)
{
boolean z = false ;
//String[] a = new String[6] ; ...
|
|
I'm trying to find a forward slash in a string...
This doesn't seem to work:
if ("/test".indexOf("/") > -1) {
What am I doing wrong?
Funny thing is... I tried this:
if ("!test".indexOf("!") > -1) {
and ... |
Is there a function or something, that is made for finding the signs in a String (e.g. +/-[]{})(). If there is such a thing, please tell or if not, just to ... |
This is a sample .txt file:
item1
item2
myString
item3
item4
I created a class to find a string in a .txt file:
public static String lineToFind;
public static boolean lineFound;
public static void findLine() throws IOException{
...
|
Ia m getting the following error while running my SIMPLE java program [ I guess!!! ], please HELP as this will lead me to make a bigger module[ mean that i ... |
I am trying to find and replace strings. Below is what I have sofar.
I am troubled on how to force all the changes to show in one line as showed ... |
I have a text file (T1.txt) in which it has few strings.out of them 2 are similar but case-sensitive. I have to ignore the other one and get the rest of ... |
Maybe I am making this too complicated but I think I need to start reading a string from the right to find its position.
Here is my sample:
10000000000000000101
In this string I ... |
If I have 2 files say ABCD.txt and DEF.txt. I need to check if the String "ABCD" is present in DEF.txt and also the string "DEF" present in ABCD.txt and write ... |
I have made a class named Entity, and have the following code:
Entity zombie1 = new Entity();
I get input 'zombie' from a scanner, and then concatenate a number, based on level on ... |
I want to find the frequency of a multiple-token-string or phrase inside a document. Its not the word/single-term frequency that I am looking for, its always will be multiple-term and the ... |
I am working in school project. In that what they told is, I will be given a String which contains an actual program like....
import java.io.*\npublic class A{\n...........EOF
And My job ... |
When I compile the code below error occurs:
canot find symbol
location: interface org.apache.commons.logging.Log Log.d(TAG,"JSON parsing error - fix it:" + e.getMessage());`
This is my code:
//convertJSONtoArray
private void convertJSONtoArray(String rawJSON){
...
|
Hi I have this project that I need to use Java to access twitter api, and I found Twitter4j easy to use and tried some samples from the site. However I ... |
Hey, I have a very big project with thousands and thousands of code lines. Until now we have used hard-coded passwords and we wish to stop. The problem is how detect ... |
|
I think a common convention in this type of situation is to define what the "data type" is. That is you get each field one at a time in a pre-defined order. Then you can use the various tools available to convert it into the internal representation you wish to use. For example, when you expect an int, you can use ... |
Hey guys, I am looking for a specific occurrence of a string in a larger string. Now im aware that the method Sting.indexOf(occurrence) will return the integer position of the first occurrence of the string im looking for, but i know that the string im looking for appears more than once in the larger string and i would like to find ... |
|
|
|
|
Does anyone have any suggestions on what I could do to figure out the width of a string? Ex: If I have two strings: "WHOOO HOOO" vs "ITTY BITTY" Both strings have the same number of letters however when I use a font that is not fixed width - then the second string takes up less room when typed. Is there ... |
|
|
I think what Henry is getting at is this: A simple search for a particular string -which happens to be a procedure name- might not be sufficient, since that string could also be part of a comment. So in the worst case, you'd have to have an actual parser for whatever syntax those file contain, in order to distinguish proper occurrences ... |
Are you asking how to determine mathematically the number of different combinations of letters, given a particular string? I may very well be wrong, but isn't it the number of characters factorial? Say you had 5 characters, 5! equals 120. There are 120 different possible ways to rearrange the characters. Or take the sequence "123". 3 characters, so 3! equals 6: ... |
|
|
I have building this program that works with exception handlers, while I believe I have it down pretty good, I am getting one type of error that I am not sure about. .\Date.java:63: ';' expected System.out.print('please enter a valid input: '); ^ .\Date.java:63: unclosed character literal System.out.print('please enter a valid input: '); ^ .\Date.java:63: cannot find symbol symbol : class enter ... |
|
hi all , this the example , i have a string contains 4 chars (A,B,C,D). size =4 , now all possibel cimbinations = N! which N = length of the String i want to find all possible combinations like ABCD ABDC ACBD ACDB ADCB ADBC BACD BADC BCAD BCDA BDAC BDCA AND etc ...... till we reached to N! . |
|
|
Hey guys, this is an interesting problem. Let's say I have a string like this: String s1 = "My name is Justin and I love writing code and writing about coding algorithms." +" In fact, some of my best days are created by working with coding algorithms." +" Even though I can't say for sure how much I truly love writing ... |
Hello, I have a string strCurrentTableRow which contains xxxxxxxxxCD01xxCD01(A)xxxxxxxxAB01xxxxxxxxxxxAB01(A)xxxxxxxxx where x is any character and the position of AB01 can change anywhere. Now, I'm using a variable strCurrentRequiredJf which will have either AB01 or AB01(A), which will be dynamic, meaning it can be CD01 or CD01(A) as well based on the stuff selected by the end user. I have an IF ... |
Hi friends, I have the following code. When I execute it is throwing this Error "cannot find symbol method getResponseHeader".. Can you Please help me to solve this Error. I have pointed all the below jar files but still Error exists. commons-httpclient-3.0.1.jar commons-httpclient.jar commons-httpclient-3.1-rc1.jar httpclient-4.1.1.jar org.apche.commons.httpclient.jar Code:- public class try2 { private static String nameSpaceID = "cogndvldap"; private static String userName ... |
|
this is the question and my code Hilan International Bank decided to have a salary plan for its employees. In the new Policy, bonus is based on the fact that one is a senior staff or junior staff. You have been called in as a programmer to develop a software to meet this policys requirement: (a.) Create a class called Salary. ... |
Hi, I have a string A= "Amsterdam" There is another string B= "amst" How do I find if String A contains B. I tried using the contains method but that is case sensitive. I also tried StringA.indexOf(StringB)>0 but this does not work if String A has a uppercase 'A' and string B with lowercase a. If String B="amst" or "Amst"(with uppercase) ... |
|
Can I just point out that those comments in your code are completely worthless. Might sound like a nitpick, but if you're not thinking about whether your comments make sense, chances are you're not thinking about whether your code does, either. Anyways, Encephalopathic seems to have a handle on your problem, but just slow down and think about what you're trying ... |
Did you see my last post? Did it stimulate you do do anything new? You know that your search is based on the carot position, correct? If the carot position isn't changed, you will continue to search based on the same spot in the string. Do you think that there may be anything in the JTextPane api (or one of it's ... |
First, learn what code tags are and how to use them on computer programming forums Then, figure out how to read in a line of data from the file into a String variable. Then look through the definition of java's String class for methods that will allow you to search the String variable for a given piece of text. Repeat for ... |
|
GaryJSF wrote: Thanks so much. I implemented the array solution and it seems to work but I am still testing it. Is there any advantaged to using the regex solution? Which one is better java standards? Since you put it that way, the array solution is better: it's pure Java, and completely transparent. You don't even need to know Java to ... |
Hi, thank you for all your tips/hints/code. @calypso : What I don't understand in your code is the global 'count' variable. I simply don't get the picture (sorry). Another question: you're talking about that s'.indexOf('toFind', 'index'+1) would shorten the code. What do I have to replace Cheers Jonny Edited by: jonnybecker on Jan 14, 2009 12:02 PM |
You might want to start by describing precisely what you want to match. If you can't describe it precisely to the forum in English, nobody will be able to help you describe it precisely to Java in regex. Also, when you post code, use code tags so it will be readable and not turn various characters into markup. When not in ... |
|
{code} RuneScape - the massive online adventure game by Jagex Ltd. |