cutting chain java [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
hello I have this string that is a data table I want to test if the string contains more than _ then we are cutting the chains and in each sub string in a table row
I use talend and my input is an excel
I'm really stuck who can help me please
exemple:
JEN3030_1_2_3
JEN3030_1
JEN3030_2
JEN3030_3

Try String.split()...
String input = "JEN3030_1_2_3"; //or whatever
List<String> output = new ArrayList<String>();
String[] parts = input.split("_");
for(int i = 1; i < parts.length; i++) {
output.add(parts[0] + "_" + parts[i]);
}

Related

How to convert String to array in Java [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 months ago.
Improve this question
I have a string String myStringArray = "[491174, 414529, 414557]";. I want output 491174, 414529, 414557 just this part. I tried many methods to convert string to array and many other things. I tried something I'm adding the code below.
My Code
String myStringArray = "[491174, 414529, 414557]";
String newArray = myStringArray.replaceAll(" ", "");
System.out.println("Before Remove : " + newArray);
String remove = newArray.replaceAll("[^a-zA-Z0-9]", ",");
String rm = remove.replaceFirst(",", "");
System.out.println("After Remove : " + rm);
Output
Before Remove : [491174,414529,414557]
After Remove : 491174,414529,414557,
As you can see I have , in the end and I don't know how to remove this ,. Please help me if you can.
rm = rm.substring(0, rm.length() - 1);

How to add a letter the end of each word per its word index? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 11 months ago.
Improve this question
I have a problem about adding a letter the end of each word per its word index.
I cannot handle with that. How can I fix it?
Here is my code shown below.
for(int i=0;i<sentenceOfArray.length;i++) {
sentenceOfArray[i] = sentenceOfArray[i] + "c";
}
Here is the solution with the usage of repeat method.
for(int i=0;i<sentenceOfArray.length;i++) {
sentenceOfArray[i] = sentenceOfArray[i] + "a".repeat(i+1);
}
Other approach:
String [] sentenceOfArray = {"abg", "ert", "mlk"};
for(int i=0;i<sentenceOfArray.length;i++) {
char lastLetter = sentenceOfArray[i].charAt(sentenceOfArray[i].length() - 1);
sentenceOfArray[i] = sentenceOfArray[i] + "c";
System.out.println(sentenceOfArray[i]+"\n");
}
Output:
abgc
ertc
mlkc

should i use remmove and is this correct in java? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
in the exercise they told if string contain 00 or 0 remove it
String rse="12+00+9+88";
String re="[0]{1,2}\\+";
String oper[]=chaine.split("[0-9]{1,2}\\+");
for(int i=1;i<oper.length;i++) {
if (oper.equals(re)) {
}
}
You may juse use String.replaceAll and use 2 regexes
(0+)\+ to remove zeros followed by a +
\+(0+), specific case when zeros are the last one, the + is before it
List<String> values = Arrays.asList(
"12+00+9+88",
"12+0+9+88",
"00+9+88",
"0+9+88",
"12+00",
"12+0"
);
for (String s : values) {
String r = s.replaceAll("(0+)\\+", "").replaceAll("\\+(0+)", "");
System.out.println(r);
}
12+9+88
12+9+88
9+88
9+88
12
12

Extract Verbs from Sentence [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I would like to know if there is a way to extract verbs from a string.
As an example :
I'll eliminate you.
I want it to only extract "eliminate".
You probably want to be looking at using the Stanford PoS tagger (http://nlp.stanford.edu/software/tagger.shtml). It will tag the string with it's classification (e.g. verb, noun). You can then use a regular expression to pull out the verbs.
ArrayList<String> verbs = new ArrayList<>();
verbs.add("eliminate");
String yourtext = "I'll eliminate you";
for (String verb : verbs) {
int index = yourtext.indexOf(verb);
if (index >= 0) {
System.out.println("Found verb: " + verb + " at position: " + index);
}
}
I'll leave filling the verbs array up to you.

php take raw input to a variable [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Consider this piece of Java code
I need to do this in php
String SEPARATOR = "S39Er#T0R";
String input = "someS39Er#T0RDataS39Er#T0Rhere";
String[] val = input.split(SEPERATOR);
for (int i = 0; i < val.length; i++) {
}
I need to store the data received from file_get_contents('php://input') which returns the raw post
and then from that string I need it to split and run a for loop
Can any one suggest how to implement the same code in php ?
explode function splits a string by a string;
preg_split splits a string by a regex;
foreach construct iterates over arrays or objects;
Combination of these is pretty straightforward:
$separator = 'S39Er#T0R';
$postData = file_get_contents('php://input');
$splitPostData = explode($separator, $postData);
foreach($splitPostData as $postDataItem)
{
// do something with $postDataItem
}

Categories

Resources