FAQ Database Discussion Community


String.split() method - order of token in the returned String array

java,arrays,string,split,string-split
I am working on a application where I have to deal with a custom variable aVar- String aVar = price/barcode/area1/true // varName/varType/varScope/tracable There may be some other attribute added to aVar seperated by a ('/'). To get varName, varType, varScope etc I have to do the following things, please see...

After compiling the code it crashes (couldn't get why)

c++,string,string-split
When i am using StrSplit function with a constant string it works great. but when i read the line from a file and then use it as string for StrSplit function my program crashes. the following is the code and the error screen shot. string Read_from_file(){ //load the text file...

How to split a text into two meaningful words in R

r,string-split,stemming,text-analysis
I had a text data frame having sentences, and as I wanted the list of separate words in another dataframe I used the "qdap package" function "all_words" Words = all_words(df$problem_note_text, begins.with=NULL , alphabetical = FALSE, apostrophe.remove = TRUE, char.keep = char2space, char2space = "~~") Now have a dataframe which has...

Exception in thread “main” java.util.regex.PatternSyntaxException: Unmatched closing

java,regex,exception,string-split
I'm trying to translate back the sentence "b((aa)a)b$" using the grammar shown in code comment. When I try to run it, it gives the following error. It seems to be an error with the string split method, but I don't know how to fix it. Any suggestions? Thanks. run: b((a)a)b$...

Go through a string and check if contains a char and save the chars before in a list

c#,string,string-split
I want go through a string, and check if in the string is a char available. For example: My string is: string test = "100+20+3-17+2" So now I go through my string and check the chars: List<string> numbers= new List<string>(); foreach( char c in test) { if (c =='+'|| c...

Vb.net Text Spliting is Null

vb.net,string-split
I just separating line by line in a text file, with this code Sub Event2() Dim Lines = File.ReadAllLines(Place + "Text.txt") Dim Srl As String = Lines.ElementAtOrDefault(1) Dim Str1() As String Str1 = Srl.Split("^") Title.Text = Str1(0) LoadIMage(pb1, Str1(1)) LoadIMage(pb2, Str1(2)) LoadIMage(pb3, Str1(3)) TxtDesc.Text = Str1(4) End Sub But when...

Splitting error eml using regex

python,regex,string-split,eml
Hi I have an undelivered report as shown. I want to parse these using regex. (<from:.* to:.*>)([\w\W]*) gives me the first how can I split into 3 emails and get only the details part. ..... ..... bhahbhahbhahbhahbhahbhahbhahbhahbhahbhahbhah..... Message-Id: <[email protected]> This is the mail gateway at gw.example.com. I'm afraid I wasn't...

Splitting string into multiple strings using LINQ

c#,.net,string,linq,string-split
I am trying to split this string string s = "sn DC0000002; mac 00:0c; uuid 564d6ae4-979"; I need to get these values from above string "DC0000002" , "00:0c" , "564d6ae4-979" For this I have tried below query but not able to able to get last two values I mean these...

Splitting a string with two different characters

python,regex,string-split
I have the following string u'root\n |-- date: string (nullable = true)\n |-- zip: string (nullable = true)\n' I would like to extract the column names. The column names have |-- before them and : after them. I could do this in two stages: s = u'root\n |-- date: string...

Python3: How to extract last field in a text file

python-3.x,string-split
I am using Python3 to search for a string in a text file, but I am unable to retrieve the last field of the match. Any idea what is wrong? Here is my code: shakes = open("CFTUTIL_idparm0.log","r") for line in shakes: if re.match("(.*) Local partner identifier (.*)", line): myPart =...

How can I display successfully a result to a form field, in javascript?

javascript,function,javascript-events,string-split,arrayjs
I don't know exactly how to set the results after using the split() function; however, I think there's something wrong with the declaration. Also, the innerHTML might not be appropriate to set the results in the textarea form element. Here's the js code: function splitNumber(){ var number = document.getElementById("pNumber"); var...

Split method to divide the address into street, city, state, and zip code and display only the street and city segments

c#,string-split
This is what I've been asked: Use a Split method to divide the address into street, city, state, and zip code and display only the street and city segments What is my error? Address format: 123 ABC Dr, Omaha, NE 12345 Here is my code: (It only shows the street...

Display first Word in String with Ruby

ruby-on-rails,ruby,ruby-on-rails-4,split,string-split
I'm using ruby on rails and I want to display only first word of string my broken code <%= @user.name %> displaying Barack Obama I would want to have it display Barack and in other place Obama. How can I split it and display it? Thanks...

Extract last word from strings

split,google-spreadsheet,string-split
In Google Sheets I have string values in cells like so: 1 Gheringhap Street, Geelong VIC 3220, Australia I want to extract the country value from the string. The trouble is the string values have different numbers of commas so it's hard to say at which position the last value...

How to get specific string from static URL

php,url,string-split
I trying to split my static URL and get its value in my SQL Query. www.mydomain.com/directory/A/37/257/file.html I want to put url values LIKE $a="A"; $b=37; $c=257; Please help me to split the above mention url. Thanks...

Get the number of characters

java,string-split
I need to get the count of each repeated characters separately....I have tried..but it returns only the count of unique count of characters... Input : SSDDVVDSSS output : S - 5 D - 3 V - 2 here is my code public class q2 { public static void main(String[] args)...

Split string at specific character SQL-Standard

string,postgresql,string-split,sql-standards
In my SQL statement I have to extract a substring from a string at the character '_'. Strings can be for example 'A_XXX' 'AB_XXX' 'ABC_XXXX', so the extracted substrings should be like 'A' 'AB' 'ABC'. In Oracle this is easy with the substr() and instr() functions: select substr('AB_XXX', 1, instr('AB_XXX',...

SPLIT using “ ” delimiter in Google Sheets won't always preserve period following number

regex,string,split,google-spreadsheet,string-split
I'm using the SPLIT function to divide text around white spaces (" ") in strings. However, the output is inconsistent when a number is immediately followed by a period. Column A below contains strings, and column B the function =SPLIT(A1," ") copied down: Note how cell B1 does not contain...

Split string into list by line separator?

java,string-split
For the string String cow = "A cow jumped \n over the \n moon." How can I split the string into a list? List<String> test = new ArrayList<String>(); Collections.addAll(test, cow).split("\n")); The code above is not working....

How to count files in FTP directory

powershell,ftp,ftpwebrequest,string-split
I have this script. I'm trying to count how many file are in. clear $ftp_uri = "ftp://ftp.domain.net:" $user = "username" $pass = "password" $subfolder = "/test/out/" $ftp_urix = $ftp_uri + $subfolder $uri=[system.URI] $ftp_urix $ftp=[system.net.ftpwebrequest]::Create($uri) $ftp.Credentials=New-Object System.Net.NetworkCredential($user,$pass) #Get a list of files in the current directory. $ftp.Method=[system.net.WebRequestMethods+ftp]::ListDirectorydetails $ftp.UseBinary = $true $ftp.KeepAlive...

Splitting string using boost spirit

c++,split,boost-spirit,boost-spirit-qi,string-split
Is it a good idea? For a reason I thought it should be faster than boost's tokenizer or split. however most of the time I'm stuck in the boost::spirit::compile template <typename Iterator> struct ValueList : bsq::grammar<Iterator, std::vector<std::string>()> { ValueList(const std::string& sep, bool isCaseSensitive) : ValueList::base_type(query) { if(isCaseSensitive) { query =...

How do I split strings within nested lists in Python?

python,string,list,nested-lists,string-split
I know how to split a list of strings into a nested list using those strings, but I'm not specifically sure how I would go about splitting those strings now into multiple strings. For example: def inputSplit(file_name): with open(file_name) as f: content = f.read().splitlines() i = 0 contentLists = [content[i:i+1]...

R: splitting string that has format like this “xxx; yyy; zzz;”

r,string-split
The raw data I got is like this and they are all in one column John;Peter;Eric; Susan;Mary;Kate; But I want to split them to three separate columns John Peter Eric Susan Mary Kate Can anyone show me how to do it in R? Thanks in advance!...

confuse create print out when create some condition in Sqlite3 with python

python,database,sqlite3,conditional-statements,string-split
I created a test database with the table name and in it there are two columns with names Words and Sentences and I want to do a search in databases (sqlite3) whether the data or the word is there or not, if there is then the system will output /...

Split string by special characters '\.'

batch-file,string-split
I have a string which ends with \.. All I want is the string before \. Ex.: My String is: D:\Work\WelCome\. Output String should be: D:\Work\WelCome Please excuse if you find this question very general. I have search on net of splitting string by special characters but did not get...

how to sub-string from string by specifying the start and end characters? [closed]

php,explode,string-split
I have some texts that are always begin with an image tag , so i want to print the text without the image by specifying the start and the end characters of the string that should be removed and get the rest of the text, something like: explode($text, '<img', '/>');...

Python Beginner split String in two strings

python,string,split,string-split
I have an IP-Range 192.0.0.2-4 as string and want to split it in two new strings ip_start = '192.0.0.2' ip_end = '192.0.0.4' so I have to search for "-" in "192.0.0.2-4" and split there, but how can I make the second string?...

Split data output of a custom post type loop

php,wordpress,for-loop,string-split
How do I split the values within a custom post type loop so that the title is in the first loop which outputs in the first DIV and the content is in the second loop outputting in the second DIV? Two loops may not be the best way to do,...

split string into array with multiple delimiters shell

arrays,bash,delimiter,string-split
I have a text file having contents in format... File=/opt/mgtservices/probes/logs is_SS_File=no is_Log=yes Output_File=probes_logs This can have around 1k records. I am reading line by line from a file. while read -r line do if [ $SS_SERVER -eq 0 ] then arr=$(echo "$line" | tr ' =' "\n") echo $arr[1] #do...

how to split all values even the empty ones in Java

java,string-split
I have this List named "lines": [|||dezd||, |a|||||||||||||||||||||||||||||, |||||dezdezd||||, |||||||||||||dezdzedze|||dezdzede|||dzedzedzed|] I implemented this: for (String line1 : lines) { String[] array = null; array = line1.split("\\|"); for(int i = 0 ;i<array.length;i++){ listOfData.add(array[i]); } } System.out.println(listOfData); The result is like this ,the problem is that some empty values between "|" didn't...

how to split lines into an from txt file into a datatable

c#,.net,parsing,string-split
I have a text file of client data that looks like this :client objects ( : (ThomasSmith :AdminInfo ( :client_uid ("{C6DD9C9C-964A-4BE5-30F1-3D64A87F73A6}") :nickName (Tom) ) :addr ("1234 Pear Street") :city (Charlotte) :state (NC) :zip (12345) :phone ("555-555-5555") :email ("[email protected]") :gender (male) ) : (Jonathan Thomson :AdminInfo ( :client_uid ("{C6DD9C9C-964A-4BE5-30F1-3D64A87F73A7}") :nickName (John)...

Code need to split string AND remove unwanted characters

c#,asp.net,string,split,string-split
I have a page which receives a list of dates in the following format via ajax: ["2015-06-02T23:00:00.000Z","2015-06-03T23:00:00.000Z","2015-06-04T23:00:00.000Z","2015-06-05T23:00:00.000Z"] I have written the following code to split the dates out: string input; using(var reader = new StreamReader(Request.InputStream)){ input = reader.ReadToEnd(); } string [] arr = input.Split(new string[] {","},StringSplitOptions.None); but i need to...

VBA loop trough split value cells and replace

excel-vba,for-loop,foreach,str-replace,string-split
I have created a macro like below in the Excel. In the column A values are separated by a semicolon. There is a loop through split values in the column A and replacing splitted values in the column B. Looping through splitted values doesn't work. Sub ReplaceAttachments3() Dim cl As...

How to write regex for this javascript string

javascript,regex,split,string-split
How to write this string below "(22.0796251, 82.13914120000004),36", "(22.744108, 77.73696700000005),48",...and so on Like this: (22.0796251, 82.13914120000004) 36 (22.744108, 77.73696700000005) 48 ...and so on.................. .. How to do this using regex in javscript ? My try is this: substring = test.split(','); where test contains the data to be formatted. But its...

split string for specific column

regex,r,order,string-split
I have a file like this: V1 V2 1 1-500891 CGCGACCTCAGATCAGACGTGGCGACCCGCTGAA 2 2-280976 AGGTTCCGGATAAGTAAGAGCC 3 3-223181 TCTTAACCCGGACCAGAAACTA I would like to split (and swap) the V1 column resulting in the following output Sequence Count CGCGACCTCAGATCAGACGTGGCGACCCGCTGAA 500891 AGGTTCCGGATAAGTAAGAGCC 280976 TCTTAACCCGGACCAGAAACTA 223181 I have tried this, but it did not work: df_split...

Splitting an input file in Java

java,split,string-split
I've spent a good couple hours trying to solve this myself, but I just can't figure it out and decided to ask. I am loading a file into my program for me to split into three fields.Each line in the text file contains 3 comma separated values double, double, char....

python for split all line and save in new output file

python,string-split
i have already this code #!usr.bin/env pyhton asal = open("honeyd.txt") tujuan = open("test.rule", "W") satu = asal.readline() a = satu.split(); b = 'alert ' + a[0]+' ' + a[1] + ' -> ' + a[2]+' '+ a[3] c = str(b) tujuan.write(c) asal.close() tujuan.close() but this code is just read a...

Java split String in three parts

java,string,string-split
I need to split String into 3 parts. Example: String s="a [Title: title] [Content: content]"; Result should be: s[0]="a"; s[1]="Title: title"; s[2]="Content: content"; Later I would like to put Title: title and Content: content in a Map as String key-value pair....

Split string using regular expression, how to ignore apostrophe?

python,regex,string-split
I am doing a spell check tutorial in Python and it uses this regular expression: import re def split_line(line): return re.findall('[A-Za-z]+(?:\`[A-Za-z)+)?',line) I was wondering if you could help me change this function so it will ignore ', i.e. if I input the string he's i will get ['he's'] and not...