Questions tagged [string]

68442 questions
1

votes
2

answer
377

Views

How to split a string with regexp without keeping capture groups?

I want to split text with a regular expression with backreference in Python. rexp = re.compile(r'([`]{1,})ABC\1') rexp.split('blahblah``ABC``blahblah') I got ['blahblah', '``', 'blahblah'] but expected ['blahblah', 'blahblah']. How can I split string without keeping capture groups?
Zz Tux
3

votes
3

answer
88

Views

What exactly does this log10(int) method in Java?

I'm checking a Java code from an online test and I try to understand what exactly is this log10() method. This is an image with the code from the test: I added the code in my Eclipse and I get some errors: public class Demo { public static String numbers(int from, int to) { int maxDigits = ceil(log...
gaby
1

votes
3

answer
40

Views

Trying to get rid of a part of a string (used as file path) in order to go back a directory

My problem is as follows. My PHP code relies on a string to determine a file directory, by removing the last part of the path. I want to go back a directory. Consider the following example: Original Input: $dir = 'this/is/a/files/location' Desired Output: $dir = 'this/is/a/files' Basically, I nee...
Karl Schmidt
1

votes
2

answer
282

Views

How to extract emojis and flags from strings in Python?

import emoji def emoji_lis(string): _entities = [] for pos,c in enumerate(string): if c in emoji.UNICODE_EMOJI: print('Matched!!', c ,c.encode('ascii','backslashreplace')) _entities.append({ 'location':pos, 'emoji': c }) return _entities emoji_lis('👧🏿 مدیحہ🇵🇰 así, se 😌 ds 💕...
Noman Dilawar
1

votes
1

answer
233

Views

The filename, directory name, or volume label syntax is incorrect - when trying to readfile in go lang

I want to read contents of text file. When I am passing the file name as string like this: stream, err = ioutil.ReadFile('sample.txt') its working. Its even working if do in this way: filename := 'sample.txt' stream, err = ioutil.ReadFile(filename) But when I get the value of filename from string a...
Varun Gupta
1

votes
1

answer
333

Views

c# String.Compare vs String.CompareOrdinal

In C#, is String.CompareOrdinal(strA, strB) equivalent to String.Compare(strA, strB, StringComparison.Ordinal)? I checked the document at https://msdn.microsoft.com/en-us/library/e6883c06.aspx and it doesn't mention this.
Roy
1

votes
4

answer
42

Views

Java Substring conditional end

I have a strings such as: String test1 = 'https://31.191.110.125:443/App/ws/list/play'; String test2 = 'https://31.191.110.125:443/App/ws/list'; I want the substring output for both the above strings to be /ws/list From /ws/ to first / or end of string if there is no / String sub = test1.substrin...
user5155835
0

votes
0

answer
12

Views

Replacing character with a string in Nginx

Is there a way I can replace # with '?somecharacter' ? What i'm trying to do is convert my URL from https://localhost/#afljkdhslfjdsaf to something linke https://localhost/?var=afljkdhslfjdsaf. While i know how to access query paramerts inside nginx block i've not idea how to capture the # and repla...
Ritesh Chauhan
1

votes
2

answer
1.9k

Views

How to read connection string inside .NET Standard Class library project from ASP.NET Core

In my solution, I have a ASP.NET Core web project and a .NET Standard class library project. Class library project is the data access layer and I want to read the connection string from my appsettings.json (ASP.NET Core project) in my data access layer. I have found few answers such as by Andrii Li...
Learning Curve
1

votes
3

answer
74

Views

String doesnt convert to int

I'm trying to get the text of an edittext and convert it to int but I'm facing this error: android.content.res.Resources$NotFoundException: String resource ID #0x5 the code is very simple: temp=String.valueOf(editm.getText()); minput = Integer.parseInt(temp); Toast.makeText(this, minput, Toast.LENGT...
Amir Rahmamzadeh
1

votes
2

answer
47

Views

how to separate letters from numbers in PHP

I have string as following: $str = 'Q1-Q4,A3-A6,S9-S11'; Can someone tell me how to split the above text in PHP so that I get following as output: Q1,Q2,Q3,Q4,A3,A4,A5,A6,S9,S10,S11
Rovin Patwal
1

votes
1

answer
39

Views

C-Linked-List: How do I save the 'Head' in a 'Temp' var so I don't have to traverse backwards each time

If I traverse my linked list for any reason, print, sort, etc... I have to re traverse it backwards to reset the head. Is there a better way to do this? struct list_node { struct list_node *next; struct list_node *prev; char word[30]; int word_count; }; typedef struct list_node list_node; struct li...
seamus
1

votes
1

answer
91

Views

Checking if a string hash contains a substring hash

Let's say I have a ton of documents that I somehow hash (e.g. Sha256) and store their hashes. Is there a hashing technique that would allow me checking if string1 is contained within string2, by just looking at their hashes? I want to avoid loading the full text. To clarify: this is unrelated to sim...
Hristo Yankov
1

votes
2

answer
60

Views

How do you best format very long string constants in C? [duplicate]

This question already has an answer here: Defining a string over multiple lines 3 answers How to split a string literal across multiple lines in C / Objective-C? 8 answers I have this: char * str = 'hahahahahihihihihohohohohahahahahihihihihohohohohahahahahihihihihohohohohahahahahihihihihohohohohah...
Theo Freeman
1

votes
1

answer
36

Views

Converting cell values to snake_case

I have some data cleansing task. I have a column which start from H6 and further down from their. The column contains data which was supposed to be in snake_case, but is not the case. The cell values are of the form: With camel case: 'CamelCase' With spaces: 'Spaced Value' With some initial call cap...
anir
1

votes
1

answer
48

Views

Javascript typescript append special character to string is not working

I am about to append a string conditionally, with values coming from captured DOM elements. For cases of empty, I want to append the string with the character '¬'. Although, this drives to append the string with � possibly because the above special character is not recognized. Here is the code sa...
George George
1

votes
1

answer
40

Views

Allow only single type of mark in string

I'm trying to figure out, how to allow only single type of mark in string. For example if string inputStr contains different marks: string inputStr = 'hello, how are you? ~ say something: what's up? hi... tell me. what?! ok: so,'; this way: string outputStr = Regex.Replace(inputStr, @'[^\w\s]', '');...
sam324
1

votes
1

answer
41

Views

reading multiple lines of text until blank line

I'm working on a program that gets the user to enter text until the program reads a blank line. So far, I have this: #include #include int main() { string text; cout
firenation1254
1

votes
1

answer
75

Views

Most used Strings in IntelliJ

Is there a way to detect, if any hard-coded string is repeated more than x times in the whole project? Let's say I have a project with multiple folders and classes and I have a separate class called Constants, where I store all my project constants. Since the project is getting bigger, it will be ni...
Andrei Suvorkov
1

votes
3

answer
25

Views

Android Dynamic String: %1d vs %1$d

Is there a difference between a format string with the $ included? %1d vs %1$d I noticed that in the app code we have both and both seems to work ok. or by the way using %1d to %2d vs %1$d to %2$d
htafoya
1

votes
3

answer
54

Views

How to split comma, semicolon and comma separated phrases with semicolons around?

How to split comma, semicolon and comma separated phrases with semicolons around where it should treat anything between semicolons with a comma as the delimiter, but also delimit just comma and semicolon all together in funcion? String of words: var words = 'apple;banana;apple, banana;fruit' Regex f...
AlexFF1
1

votes
4

answer
52

Views

How to replace a string in a dataframe column with another in Python Pandas?

I have a dataframe called df_cv with column that contains this string _log. I would like to delete _log from the name of each column in a dataframe So i didlike this : modify_cols=[] for c in df_cv.columns: if c.find('_log') != -1: modify_cols.append(c) for c in modify_cols: c = c.replace('_log','...
Nasri
1

votes
2

answer
51

Views

How to search in array with LIKE operator

id | name | ipAddress ----+----------+------------------------- 1 | testname | {192.168.1.60,192.168.1.65} I want to search ipAddress with LIKE. I tried: {'$mac_ip_addresses.ip_address$': { [OP.contains]: [searchItem]}}, This one also: {'$mac_ip_addresses.ip_address$': { [OP....
YOGESH MISHRA
1

votes
1

answer
34

Views

Printing std::strings produces no output

I was building a small template stack class for a side project and it appeared to be working correctly. However, when I tried it with strings it doesn't appear to work. I have no compilation errors or warnings. I simply get no output. I'm a little rusty in C++ but I wasn't expecting to get blocked b...
Pedro Alves
1

votes
2

answer
61

Views

How to pass string as object name?

Here's how I finally solved the problem: I created two lists, one containing the objects, the other containing the object names (strings). Then I write in the code to make sure that an object and its name are appended to the two lists at the same time. So that I can easily call an object with Object...
JustCallMeGary
1

votes
2

answer
56

Views

Converting a string using the Double.TryParse method in C#

Right now, I converted all 3 strings into an int, but I'm having trouble converting each string using the Double.TryParse method. I want to use that method instead of int. I tried using this type of code if (Double.TryParse(value, out number)), but I'm not to sure exactly if this is right. //Ask the...
user10636563
1

votes
1

answer
16

Views

Splitting chain into data.frame with from and to fields

I have vectors looking like var a %->% var b %->% var c %->% var a. The %->% denotes arcs. I want to split those vectors in data.frames of the form: from to 1 var a var b 2 var b var c 3 var c var a I found two versions which both seem overlycomplicated. Version 1: with a for loop. Does what I wa...
symbolrush
1

votes
2

answer
51

Views
1

votes
1

answer
38

Views

How to correctly identify float values [0, 1] containing a dot, in DataFrame object dtype?

I have a dataframe like so, where my values are object dtype: df = pd.DataFrame(data=['A', '290', '0.1744175757', '1', '1.0000000000'], columns=['Value']) df Out[65]: Value 0 A 1 290 2 0.1744175757 3 1 4 1.0000000000 df.info() RangeIndex: 5 entries, 0 to 4 Data c...
Julian Drago
1

votes
1

answer
30

Views

How can I draw a UML class that must be a valid IP address

I want to be able to draw a UML diagram of my code that utilizes IPv4 addresses. They are normally just a string but they must be created in a very specific way to be valid. Here is the regex for one: \b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\. (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\. (25[0-5]|2[0-4]...
Interlooper
1

votes
4

answer
41

Views

Check string for specific format of substring, how to..?

Two strings. My items name: Parfume name EDT 50ml And competitor's items name: Parfume another name EDP 60ml And i have a long list of these names in one column, competitors names in other column, and I want to leave only those rows in dataframe, that have same amount of ml in both my and competitor...
milka1117
1

votes
2

answer
45

Views

How to convert a JsonNode containing a list of string to a comma separated string in Java

JsonNode: { name: ['bishal', 'jaiswal', 'Turtle'], title: 'jaiswal' } I want to extract the list of name from jsonNode as a comma separated string in an efficient way: Output: nameList ='bishal,jaiswal,Turtle' Apart from converting the jsonNode of name array to a list & then using the join method to...
Bishal Jaiswal
1

votes
2

answer
47

Views

why different string pointers to the same content have the same adders in c? [duplicate]

This question already has an answer here: C optimisation of string literals 2 answers I assign two different pointers with the same content(not value!) to strings and when I print they address I saw they have the same adders and the none pointer string has different adders, can someone explain why...
Hillel Horgen
1

votes
3

answer
39

Views

How to make a function that takes two sets with strings that returns the equivalent values? (Javascript)

//EDIT: I'm using Codehs for this problem and it doesn't use filter or has' function start(){ var gifts = ['book','car']; var presents = ['game','book']; var tim = new Set(); var sally = new Set(); tim.add(gifts); sally.add(presents); var ans = compare(tim,sally); println(ans); //should print in...
Harry
1

votes
3

answer
25

Views

How to split a string by dashes and removing any outer white space?

Goal: I want to split a string by dashes, where each array item excludes any spaces. Example: string --> 'CL - Destination - Airport Tax' Ive tried : var splitArray = section.split(/[-]+/); Expected: splitAray [0] = 'CN' splitAray [1] = 'Transit ' splitAray [2] = 'Airport Tax' Actual: splitAray [0...
Kode_12
1

votes
5

answer
21

Views

How to evaluate a string input and check if it is a decimal

I use python 3 and am trying to figure out how to evaluate a user input string and check for certain characters. I know that this title is probably going to make it sound like I haven't heard of the .isdecimal() method, but in fact I am trying to allow for a user to input some number as a decimal, i...
JWilliams12117
0

votes
4

answer
23

Views

Add string at the end position of particular text in a string

I need to append a text at the end position of the search term. $baseStr = 'www.abc.com/cdf/?x=10'; $searchStr = 'www.abc.com/'; $insertStr = 'xxx/'; I need to insert $insertStr after 'www.abc.com/' in $baseStr. I get only the start position using strpos. Expected result: $resultStr = 'www.abc.com/x...
Vinoth S
0

votes
1

answer
24

Views

Splitting string into multiple columns based on symbol

I have one column in a dataframe that contains either a four digit number (e.g. 4567), a five digit number (19282), a four and a five digit number separated by a slash (e.g. 16726/2625 or 8728/16292) or two five digit number separated by a slash (e.g. 37647/38838). I want to split the values in this...
Antje Rosebrock
0

votes
1

answer
22

Views

Program to find vowels, If statements not assigning correct values

I have a simple program to find the vowels in a string. The for loop is supposed to iterate through the string and see if the char matches any of the vowels using and if else block but the output is just 100 As. I tried making them all just ifs but that gave all Us. #include int main() { const in...
C.Deighton
1

votes
1

answer
13

Views

How to compare string value by index and column and apply AND OR logic within dataframe?

I have a dataframe that looks like this: col1 0 ofcourse 1 I love the service The dataframe could also have this value for row 1: col1 0 ofcourse 1 I hate the service I want to compare the value of the strings by row and column and be able to check for one of two values in row1. I want to creat...
RustyShackleford

View additional questions