Category "string"

How to format a string in Python source code for improved readability [duplicate]

I'm building a rather long file path, like so: file_path = f"{ENV_VAR}/my_dir/{foo['a']}/{foo['b']}/{bar.date()}/{foo['c']}.json" This is a s

Javascript method to capitalize the first letter of every word and also every word after hyphen or dash

I need a JavaScript method to allows me to convert the first letter of every word in a string to a capital letter like this: mike tyson wayne to Mike Tyson Wayn

Can't remove backslash from string in Python

I want to remove backslash from a string, I tried result.replace('\\','') but nothing changed. Anyone has an idea how I can remove it? result = '[(\'company_ids

Find if two strings are anagrams

Faced this question in an interview, which basically stated Find if the given two strings are anagrams of each other in O(N) time without any extra space I tr

Return a dictionary from multiple line string in swift

I am new to swift. Is there a simple way to convert the following string to dictionary format. Example: input = "Name: Jack\\n Area: Place\\n FavColor: Blue\\n"

How can we extract a next numeric value to a string in python

There is a need that I have a taken a output in a string such as string is "Initial: [818 v1] any other string or words here" and here I want to take 818 from t

Speed up millions of regex replacements in Python 3

I have two lists: a list of about 750K "sentences" (long strings) a list of about 20K "words" that I would like to delete from my 750K sentences So, I have to l

How to remove substring starting with RT and ends with ":"

I have a dataset with a column consisting of tweets. Some tweets are retweets, which start with RT @username: ..... I would like to remove this part of the stri

Check if string exists in list made with data from a csv file

I import data from a csv file and then store it in a list (List<Customer> customers). The data is added to the list by creating and adding objects. The ob

How to write millions of double values into a txt file

I've made a neural network and now I need to save the results of the training process into a local file. In total, there are 7,155,264 values. I've tried with a

Keyword repeated multiple times in context from string in R

I have a dataset (z) with strings which are very long in z$txt. I also have a dictionary (incd) of keywords that need to be identified. In the column z$inc.term

How to insert text after a certain string in a file with variables

I have these variables: file_path="/home/dir/file.xml" string="<host mac='0A:00:DD:D2:00:02' name='vfp-20vr' ip='10.10.1.122'/>" This is the content of f

I need a function to delete certain characters from a char array in c++ without using any index

for example: if the user enters : ( 23+22+43) I want the function to do exactly the following : for(int i =0; i <strlen(x);i ++) { if (x[i]=='+') {

How do I change the only the first word of every line in a text file?

So I have actually worked out how to change the first word but the problem is its not just changing the first word only. So i have a file such as : 2 0.268278 0

How can I sort a list of strings in ascending order of numeric part

I have a list of paths which have multiple numerical parts within them, here is part of it: 'C:\\Python\\Python310\\Scripts\\mockup_test\\17mm.JPG', 'C:\\Python

Regex for double quotes inside string

A follow up to my previous question here. I realize I need to be more specific regarding my regex case to get an answer that works for my case. I am fighting w

Split numbers and dates into separate columns

My data contains text strings with three important features, an id number separated by":" and a starting date and an end date. I need to get these tree numbers

c# StringExtension with Method Space

I try to create a string extension with the method Space(int) in it. If I have an instance of a string, then its no problem. But without I have no Idea. The cal

Splitting a Rust string into a Vec of its substrings with contiguous identical characters

I have a string or a &str of ASCII characters and I want to separate it into a Vec of all substrings with contiguous identical characters (for example, "aab

ValueError: could not convert string to float: '<kivy.uix.textinput.TextInput object at 0x0000011D49678430>'

I'm new at python and right now i try to make similar calculator with user input. I rewrote my code but its still dont work fine. Cant convert string property t