Questions tagged [split]

Use this tag for questions about separating an item (e.g. a string) into parts, often by a delimiter or regular expression.

It is most often applied when splitting a string by a delimiter, such as when parsing a comma separated value file. Some languages such as Ruby and Java support splitting a string according to regular expression as well.

A split string produces an array of strings.

split can also refer to

  1. the split function
  2. the String#split method
  3. the str.split method
  4. the explode function.
  5. the split method
  6. the split method
  7. the // String.Split method
  8. the / split command line utility
  9. the STRING_SPLIT function

All these functions/methods split strings on a delimiter.

The split function in divides data into groups by a specified factor.

24261 questions
5
votes
3 answers

JsonMappingException with Apache Camel

I am getting below exception with Camel Route Caused by: com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.apache.camel.converter.stream.InputStreamCache and no properties discovered to create BeanSerializer (to…
Jaydeep Patel
  • 2,394
  • 1
  • 21
  • 27
5
votes
3 answers

Pandas split dataframe into multiple when condition is true

I have a dataframe, like df below. I want to create a new dataframe for every chunk of data where the condition is true, so that it would be return df_1, df_2....df_n. | df | | df_1 | | df_2 | | Value | Condition | |…
S.B.G
  • 290
  • 3
  • 16
5
votes
4 answers

Regex or split in python for shell awk equivalent

I've a agent version file that I need to parse to get the application version details. The (example) contents of version file /opt/app_folder/agent_version.txt is as below: Version: 10.2.4.110 Pkg name: XXXX-10.2.4-Agent-Linux-x86_64 Revision:…
Marcos
  • 845
  • 3
  • 10
  • 21
5
votes
1 answer

Pyspark, Add a character in the middle of a string

Let's say I have a column of Strings like this Hour 0045 2322 And I want it to become like this: Hour 00:45 23:22 In order to after turn into a timestamp. How would I go about it?
BryceSoker
  • 624
  • 1
  • 11
  • 29
5
votes
3 answers

How to split a string depends on a pattern in other column (UNIX environment)

I have a TAB file something like: V I 280 6 - VRSSAI N V 2739 7 - SAVNATA A R 203 5 - AEERR Q A 2517 7 - AQSTPSP S S 1012 5 - GGGSS L A 281 11 - …
5
votes
2 answers

Split text by sentence but not by special patterns

This is my sample text: text = "First sentence. This is a second sentence. I like pets e.g. cats or birds." I have a function which splits texts by sentence library(stringi) split_by_sentence <- function (text) { # split based on periods,…
WinterMensch
  • 643
  • 1
  • 7
  • 17
5
votes
7 answers

Java - How split(regex, limit) method actually works?

I am trying to understand how the split method works and have a slight confusion about it. In this Example given in the documentation pages of oracle, String str = "boo:and:foo"; String[] str1 = str.split("o",2); Output b o:and:foo This is easy…
Shad
  • 1,185
  • 1
  • 12
  • 27
5
votes
2 answers

Is it possible to split a String around "." in java?

When I try to split a String around occurrences of "." the method split returns an array of strings with length 0.When I split around occurrences of "a" it works fine.Does anyone know why?Is split not supposed to work with punctuation marks?
Range
  • 689
  • 1
  • 8
  • 14
5
votes
1 answer

GWT code-splitting pattern for ClientBundle image resources

In my GWT large project, I have a ClientBundle for my image resources. I defined about 40 GIF files inside it. (size of each file is about 5KB) Then I create a class with a static method to set the proper image to the obj that get as parameters: …
Nav
  • 4,450
  • 10
  • 53
  • 84
5
votes
4 answers

How split() method works in java?

My question is why the following program: // Java program to demonstrate working of split(regex, // limit) with high limit. public class GFG { public static void main(String args[]) { String str = "geekss@for@geekss"; String…
Ashutosh Tiwari
  • 311
  • 2
  • 8
5
votes
3 answers

Chunk array by element

How can I chunk array by element? For example lodash has this function chunking arrays by lengths _.chunk(['a', 'b', 'c', 'd'], 2); // => [['a', 'b'], ['c', 'd']] _.chunk(['a', 'b', 'c', 'd'], 3); // => [['a', 'b', 'c'], ['d']] So I have an array…
Hayk Safaryan
  • 1,996
  • 3
  • 29
  • 51
5
votes
2 answers

Scala : How to split words using multiple delimeters

Suppose I have the text file like this: Apple#mango&banana@grapes The data needs to be split on multiple delimiters before performing the word count. How to do that?
Ankita
  • 480
  • 1
  • 6
  • 18
5
votes
6 answers

RegEx in JavaScript .split()

I need to split up a string like this

foo

bar

to an array with "foo" and "bar" I thought RegEx could help me, but it seems I didn't understand RegEx. This is my try. var inputText = "

foo

bar

"; splittedSelection =…
Yashia
  • 90
  • 1
  • 5
5
votes
3 answers

How to split string according to regex in bash script

I have such a string: msg='123abc456def' Now I need to split msg and get the result as below: ['123', 'abc', '456', 'def'] In python, I can do like this: pattern = re.compile(r'(\d+)') res = pattern.split(msg)[1:] How to get the same result in…
Yves
  • 11,597
  • 17
  • 83
  • 180
5
votes
4 answers

How to split a number into its digits in APL

In APL, how can I split an integer or number into a vector containing its digits? What is the most concise (shortest) way of doing this?
lmq_305
  • 65
  • 6