Questions tagged [string]

54866 questions
1

votes
1

answer
55

Views

How to extract an Integral pattern out of a String using Regular Expressions

I am trying to make a mapLoader, which reads in a text file (here is an example) of the file [5,3,3,900,3,89,3,3,3,3,3,430,3,1439,3,65,3,320,3,3,3,3,3,3] [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,21,3,3,3,3,3] [5,3,3,900,3,89,3,3,3,3,3,430,3,1439,3,65,3,320,3,3,3,3,3,3] [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3...
Loligans
1

votes
2

answer
3.2k

Views

Can't make readdir accept string var

Error: readdir() expects parameter 1 to be resource, string given $directorypremium = 'uploads/premium/'.text2url($pseudo_cookies).'/'; while($file = readdir($directorypremium)) { if($file != '.' AND $file != '..') { $taille_fichier = filesize($directory.$file); $taille_fichier = round($taille_fich...
Dorian_gd
1

votes
2

answer
5k

Views

The name does not exist in the current context - grrr

In the following code, no matter what I try, the name strSide "does not exist in the current context", when I place a break point as shown. I want strSide to contain the last character in rawId and then to strip that character so that the value of rawId will convert to an integer. I don't get a co...
Cliff W Estes
1

votes
1

answer
2.6k

Views

How do I group similar strings in R? [closed]

I have a database with ~5,000 locality names, most of which are repetitions with typos, permutations, abreviations, etc. I would like to group them by similarity, to speed up further processing. The best would be to convert each variation into a "platonic form", and put two columns side by side, wit...
Rodrigo
0

votes
2

answer
25

Views

summarize from string matches

I have this df column: df df Strings 1 ñlas onepojasd 2 onenañdsl 3 ñelrtwofkld 4 asdthreeasp 5 asdfetwoasd 6 fouroqwke 7 okasdtwo 8 acmofour 9 porefour 10 okstwo I know that each value from df$Strings will match with the words one, two, thre...
Chris
0

votes
2

answer
20

Views

Javascript .replace() does nothing to string

As a web developer with over 2 years of experience, I am embarrassed to ask this but - the following code does not work as intended : var string = "Daln, nik, But, Blaz, wan"; string = string.replace("/[^a-zA-Z,]+/g", ""); if the string is not being stripped of the spaces, I mean even if I set this...
1

votes
1

answer
8.5k

Views

Write to file using ObjectOutputStream without overwriting old data [duplicate]

This question already has an answer here: How to write data with FileOutputStream without losing old data? 2 answers I need to write strings on an file on eclipse without overwriting old strings. The function would be something like: create a string, save it on the file, create another string, save...
masmic
1

votes
3

answer
233

Views

Why cant I read whole line along with double using Scanner(System.in)?

What actually happens here ? Why can't I store a String with spaces in between as name ? I tried the delimiter thing, but didn't worked. Is there a way that will produce the desired output ? I know .next() works but we might need to store a string with space. Just curious ... Scanner input=new Sca...
Prashant Ghimire
1

votes
5

answer
925

Views

Pass string literal as char* via argument

I made a function which change string, see the following code. void Test(char* str, char c) { str[1] = c; } int main(){ Test("Hi", '2'); } I notice it made some run time error. I know how to prevent the error. char buff[3] = "Hi"; Test(buff,'2'); but I don't know why the first example made run time...
Sehui
1

votes
1

answer
411

Views

Connectionstring issue. c# sql express 2012.

Here is my connection string. string connectionString = @"Data Source=.\SQLEXPRESS;Database=dbo.Employee; User Id=user1; Password=Password11"; I have a database called Employee with a table called [EVUSERS] in the dbo schema. I have created a database login under sql logins for this username an...
1

votes
3

answer
809

Views

Cannot make a static reference to the non-static method getVideoURL() from the type Cmd

I'm getting an error stating: "Cannot make a static reference to the non-static method getVideoURL() from the type Cmd CustomListViewAdapter" on the line: String txt=Cmd.getVideoURL(); The issue is being cause by this line: public String getVideoURL() { return videourl; } in Cmd.java I've tried...
Valdimárr Olaf
1

votes
3

answer
230

Views

Does strcmp(s1,s2) compare only first non equal character value of s1 and s2?

I am not convinced by the definition of strcmp(), it says it will compare entire strings (the two strings passed in as parameters, and returns -1, 0, 1 based on s1s2. If so, how do you justify below snippet from K&R, after very first non-equal character encounter, you exit out of loop. How are we co...
David Prun
0

votes
0

answer
29

Views

xor operation in java for strings to check if they are same

I have 2 strings. I want to xor those and get a boolean result indicating whether they are same(true) or not(false). Eg - "1234" xor "45677" is 'false' "1234" xor "1234" is 'true'
javaProgrammer
-3

votes
0

answer
22

Views

I am not able to understand purpose of counting backslashes in below code

From this site, I found below code. Here is the Gist of code import re def test_patterns(text, patterns): # Look for each pattern in the text and print the results for pattern, desc in patterns: print("'{}' ({})\n".format(pattern, desc)) print(" '{}'".format(text)) for match in re.finditer(pattern,...
TapanHP
1

votes
10

answer
1.6k

Views

PrefixAgain solution in codingbat

I'm currently doing codingbat problems for fun, and I just done this problem. "Given a string, consider the prefix string made of the first N chars of the string. Does that prefix string appear somewhere else in the string? Assume that the string is not empty and that N is in the range 1..str.length...
morbidCode
1

votes
1

answer
55

Views

Case being skipped and sent to catch?

When running this code case 6 is being skipped and sent to the catch statement. The user is supposed to enter his/her in put all on one line ( Ex. 6 4 10 ENTER) and then the numbers are supposed to be split by the StringTokenizer and then added in the while statement, But instead is sent to the catc...
sirnomnomz
1

votes
2

answer
1.9k

Views

Splitting string using backslash using regex

For a python program I have an input that I am taking from stdin and the input is something like: "-------/--------\---------/------\" When I print it out as a string value it is printed as it is. I am trying to split the string into a list of strings based of forward and backward slash while keepi...
mbbce
1

votes
3

answer
60

Views

String Manipulation with Regular Expression specifically or statements

I am trying to parse out certain strings from a phrase. This is the phrase: '1st Floor 2nd Floor 3rd Floor 4th Floor' The end phrase should be: '1st Floor','2nd Floor','3rd Floor','4th Floor' I am having trouble getting the '1st','2nd','3rd','4th' parts of the regex. I know I can do a less-intuitive...
user3683871
0

votes
3

answer
44

Views

Why does %c print '?' and what is its meaning

Two examples printf("\n %c , ((unsigned char)a[i]+100); printf("\n %c , -11); Returns ? ?
seamus
0

votes
1

answer
26

Views

Beginner String Array Manipulation

I am having trouble with one of my assignments. I completed the code and have to submit the assignment that will auto grade it using a bunch of tests. I got all but two of them to pass. I don't know the code for the tests. I am assuming it's coming from this method: /** * _Part 2: Implement this met...
Josh Miller
1

votes
1

answer
2.8k

Views

Using PowerShell to find the differences in strings

So I'm playing around with Compare-Object, and it works fine for comparing files. But what about just strings? Is there a way to find the difference between strings? CompareTo() is good about reporting that there is a difference, but not what the difference is. For example: PS:> $a = "PowerShell roc...
James Brown
1

votes
3

answer
444

Views

Loss of data while building a std::string from const char * or LPCSTR

I have a Function which returns a LPSTR/const char * and I need to convert it to a std::string. This is how I am doing it. std::string szStr(foo(1)); It works just fine in all the cases just when foo returns a 32 characters long string it fails. With this approach I get "". So I thought it had to do...
Genocide_Hoax
1

votes
3

answer
11k

Views

Java (eclipse): How to call a int or string from another class in same project?

How can I use an int or string from another class in same project, for example, here we go with a class called Estadisticas: public class Estadisticas { public void stats() { final String c1 = "Tu personaje"; final int Nivel = 1; final int Salud = 50; final int Ataque = 2; final int Defensa = 1; fin...
Cristobal Ruiz
1

votes
4

answer
1.2k

Views

convert string to multiple strings

Stuck on this little project. Can't figure out how to split a String into multiple strings inside a String[]. Example: String exampleString = "one two three four five"; String[] exmplString = {"one", "two", "three", "four", "five"}; What I have: static File interfacepath; FileReader fr; BufferedRead...
Ryan
1

votes
1

answer
2k

Views

Get the word right before the coma with javascript and regex? [duplicate]

This question already has an answer here: capturing group in regex 3 answers Hi im trying to get the word right before the coma in a sentence. For example if the string is: "Cloudy, and 51 ° F " I want the output CLOUDY. How is this done in regex and javascript? I know you have to use the .match c...
gregyjames
1

votes
2

answer
104

Views

Infiny calculator

I'm trying to make an infinity calculator (with numbers upper and lower than an int size), only working with strings. I'm doing addition but i meet problems when i need to report tens to the next character : like 9 + 7 = 16 i will put 6 in the current character and 1 to the next char of my result st...
Robin
1

votes
7

answer
93

Views

Get a part of string

I have a string as "cmp197_10_27_147ee7b825-2a3b-4520-b36c-bba08f8b0d87_TempDoc_197" I want to fetch the last digits(i.e. 197) For obtaining same i have implemented below code int lastUnderscore = addUcoid.LastIndexOf('_'); string getucoid = addUcoid.Substring(lastUnderscore).TrimStart('_'); The get...
ajita srivastava
1

votes
1

answer
156

Views

Reusing sinkFile with Haskell Conduit

I want to send a list of Photos to a sink to save them on the disk. Each Photo structure contains a content field of type lazy ByteString. Basically I want to do something like that: CL.sourceList photos $$ sinkPhotos I would like to reuse CB.sinkFile in my sink since, if I understand correctly, it...
z1naOK9nu8iY5A
-2

votes
2

answer
35

Views

Why can't I initialize a typedef struct string or char as normally?

I'm begginer in programming and C++. Programming on Linux, I am creating a typedef struct as below: typedef struct { char id[10]; string name[20]; }Employee; Usually, when not using struct, I initialize string char doing: char id[10]="ID02093"; string name="Joe"; So, why can't I initialize char...
1

votes
1

answer
13k

Views

Passing strings by reference and value in C++

I want to declare a string, initialize it by passing it by reference, and then pass it by value to the 'outputfile' function. The code below works, but I don't know why. In main I would expect to pass the string 'filename' like startup(&filename) But that gives an error, and the code below doesn't....
Peter
1

votes
3

answer
556

Views

Permutations of English Alphabet of a given length

So I have this code. Not sure if it works because the runtime for the program is still continuing. void permute(std::vector& wordsVector, std::string prefix, int length, std::string alphabet) { if (length == 0) { //end the recursion wordsVector.push_back(prefix); } else { for (int i = 0; i < alp...
Kthieu
1

votes
4

answer
1.5k

Views

Splitting a string into multiple Arrays

For my program, the input from the user will be something like this: {1,2,3} {1,2} {4,5,6} There can be multiple { } with any number of ... numbers inside. I already made a 2 dimensional array with an array for each sequence of numbers: {} I am having troubling splitting them into their respectiv...
Serpace
1

votes
5

answer
7.1k

Views

To get the value after space in String Java

I have String of values . Like as String line= "cpu 74608 2520 24433 1117073 6176 4054"; i just want to extract these Values and store them in different variables. Is there any way that i can get the Numeric values after every space ??
androidcodes
1

votes
1

answer
1k

Views

Iterate Generic List of Strings (Lync chatroom members) in Powershell

I can't iterate through a Generic List of Strings in Powershell. The Object is the members of a Lync chatroom. Command to get the Generic List: $crMembers = get-csPersistentChatroom -identity "XXXX" | select members The error I receive when trying to read the Strings in the Generic List is: WARNING:...
Plarsen
0

votes
1

answer
27

Views

How to enumerate string from a vector of alphabets

I have the following vector of alphabets : my_alphs
scamander
1

votes
2

answer
21

Views

Opening Xcode project with two pods installed

I'm trying to add to my app both Moltin and Firebase pods. I know that if I want to open the file (with only one pod installed) I need to open it from the .xcworkspace file instead of using the .xcodeproj file. Which file do I have to open if I have more than one pod installed (and so two .xcworksp...
Nicop.dev
1

votes
1

answer
9.2k

Views
1

votes
1

answer
40

Views

Python string encode

I have this code att=att.replace("à","a") but I received this error... att=att.replace("à","a") UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128) How can I fix?
Usi Usi
1

votes
2

answer
952

Views

Java: Find the longest sequential same character array

I am a new guy to java. I want to find the longest sequential same character array in a input character arrays. For example,this character array bddfDDDffkl, the longest is DDD, and this one: rttttDDddjkl, the longest is tttt. I use the following code to deal with this problem. But, I want to impr...
Ke Tian
1

votes
2

answer
1.6k

Views

Unity3d Input field text cut off when getting from script?

When [email protected] is entered into the input field, I am able to get the value "[email protected]" from MonoDevelop. However, when [email protected] is entered into the input field, I am only able to get the value "[email protected]". In this case, the characters "extra" seem to be cut...
Ama Mos

View additional questions