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
8 answers

How to check if a string contains a WORD in javascript?

So, you can easily check if a string contains a particular substring using the .includes() method. I'm interested in finding if a string contains a word. For example, if I apply a search for "on" for the string, "phones are good", it should return…
Khadar111
  • 151
  • 2
  • 3
  • 12
5
votes
3 answers

javascript split and JSON.parse

I want to parse array in JSON format using javascript. I have written following code. var data = "abc, xyz, pqr"; var data_array = data.split(','); var data_parsed = JSON.parse(data_array); alert(data_parsed); It gives me the error of JSON.parse I…
gautamlakum
  • 11,815
  • 23
  • 67
  • 90
5
votes
1 answer

What would be a good split character for splitting concatenated base64 strings?

I have a number of base64 strings that I need to concatenate to send over HTTP. Is there a good character to use to split the strings (I'm guessing a character that is invalid inside a base64 string). -thanks for the help
Alex KeySmith
  • 16,657
  • 11
  • 74
  • 152
5
votes
3 answers

Split a string at every 4-th character?

I have a string which i have to split into substrings of equal length if possible. I have found this solution which will only work if the string length is a multiple of 4. String myString = "abcdefghijklm"; String[] split =…
Trillian
  • 411
  • 4
  • 15
5
votes
2 answers

What to call a function that splits lists?

I want to write a function that splits lists into sublists according to what items satisfy a given property p. My question is what to call the function. I'll give examples in Haskell, but the same problem would come up in F# or ML. split :: (a ->…
Norman Ramsey
  • 198,648
  • 61
  • 360
  • 533
5
votes
4 answers

Split a wstring by specified separator

I have a std::wstring variable that contains a text and I need to split it by separator. How could I do this? I wouldn't use boost that generate some warnings. Thank you EDIT 1 this is an example text: hi how are you? and this is the code: typedef…
Stefano
  • 3,213
  • 9
  • 60
  • 101
5
votes
1 answer

Splitting Angular CLI application in two builds

I have an angular solution build on Angular 7 using the CLI. The app has 2 areas. They are not connected in any way, but they use the same code base. Right now I can go to http://localhost:4200/app1, or http://localhost:4200/app2. But they are…
Johansrk
  • 5,160
  • 3
  • 38
  • 37
5
votes
1 answer

How can I divide/split up a matrix by rows between two other matrices?

I have a matrix and a vector each with 3000 rows: fe = [-0.1850 -0.4485; ... -0.2150 2.6302; ... -0.2081 1.5883; ... -0.6416 -1.1924; ... -0.1188 1.3429; ... -0.2326 -2.2737; ... -0.0799 1.4821;…
edgarmtze
  • 24,683
  • 80
  • 235
  • 386
5
votes
4 answers

How to select the nth item in a field with separated values in a SQL database table?

So, we got a code field with separated values like 'a_bb_ccc_dddd' and need the third value, that's 'ccc'. I actually get the first with top N. DECLARE @table1 TABLE (path VARCHAR(MAX)); INSERT INTO @table1 (path) VALUES ('a_bb_ccc_dddd'),…
5
votes
7 answers

Split delimited file into smaller files by column

I'm familiar with the split command in linux. If I have a file that's 100 lines long, split -l 5 myfile.txt ...will split myfile.txt into 20 files, each having 5 lines, and will write them to file. My question is, I want to do this by column.…
Stephen Turner
  • 2,574
  • 8
  • 31
  • 44
5
votes
2 answers

PL/SQL Split, separate a date into new dates according to black out dates!

I have lets say a "travel date" and black out dates. I will split the travel date into pieces according to the black out dates. Note: Travel Date can be between 0 - 9999 99 99 Sample: Travel Date: Travel | START DATE | END DATE T | 2011 01 04 |…
ahmet
  • 1,085
  • 2
  • 16
  • 32
5
votes
1 answer

How to sort files and move to their respectable directory (c#)

So the issue I'm having is if a xml file contains "ONE" then it should move to the credit directory, else move to debit directory. Here is my current solution: private void SplitAndMoveCreditCamts(FileInfo f) { if (v.Elements().Contains(x…
5
votes
5 answers

Powershell change extension

I have a problem with change extension of a file. I need to write a script which is replicating data, but data have two files. Filename is not a string, so we can't use normal -replace I need to get from filename.number.extension this…
5
votes
4 answers

Split the string based on linefeed and map to a limited number of elements

I have a question. My input XML looks like this is line 1 this is line 2 this is line 3 this is line 4 this is line 5 this is line 6 this is line 7 .... …
Ding
  • 63
  • 1
  • 4
5
votes
8 answers

Split string into list of two words, repeating the last word

I need to split a string into a list of each two words, but repeating the last word of each pair of words. Here is what I tried, by using examples I found for other questions: line = """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do…
Litwos
  • 1,278
  • 4
  • 19
  • 44