Category "string"

Counting the number of occurrences of a string within a string

What's the best way of counting all the occurrences of a substring inside a string? Example: counting the occurrences of Foo inside FooBarFooBarFoo

Regex match whole string

I have the following pattern: [ \n\t]*([a-zA-Z][a-zA-Z0-9_]*)[ \n\t]+((char)[ \n\t]*\[[ \n\t]*([0-9]+)[ \t\n]*\]|(char)|(int)|(double)|(bool)|(blob)[ \n\t]*\[

Why is capitalizing the first letter of a string so convoluted in Rust?

I'd like to capitalize the first letter of a &str. It's a simple problem and I hope for a simple solution. Intuition tells me to do something like this: le

Extract string between the tags in Java

I have string like below Msg_Begin Some message1 Msg_End Msg_Begin Some message2 Msg_End Msg_Begin Some message3 Msg_End And want to get the message between

String comparison time complexity

Which comparison would take longer time? a = helloworldhelloworldhelloworldb = https://www.somerandomurls.com/directory/anotherdirectory/helloworld.htmlif a !=

Hex String to Byte array conversion java

I know this question is asked a lot of times but please hear me out. Previously I have tried following methods to convert hex string to byte array. say my key

Most efficient string similarity metric function

I am looking for an efficient implementation of a string similarity metric function in Python (or a lib that provides Python bindings). I want to compare strin

Pascal 'Split' Function

I am coding a little program in pascal and I have run into a small problem. In other languages there is a function named 'split' or 'explode' to take a long str

How can I fill empty space with null in a pdf? using pdfbox

I am using Java PDFBOX to read a pdf It is a very long pdf with more than 40 pages, and I need to extract more than 100 elements on each page, doing it manually

Isn't a 2-byte char datatype insufficient to deal with the concept of "characters" in a Unicode string?

Various programming languages use a 2-byte char datatype (not to be confused with C/C++'s char, which is just one byte) out of which strings are constructed. Va

Initialize a String from a range of Characters in Swift

In our code, we found a bug from not writing the alphabet correctly. Instead of "0123456789abcdefghijklmnopqrstuvwxyz", we had "0123456789abcdefghijklmnoqprstuv

Javascript: find all occurrences of word in text document

I'm trying to write a Javascript function to find indices of all occurrences of a word in a text document. Currently this is what I have-- //function that find

How can I check the first character in a string in Bash or Unix shell?

I'm writing a script in Unix where I have to check whether the first character in a string is "/" and if it is, branch. For example, I have a string: /some/dire

string split with expand=True. Can anyone explain what is the meaning?

all_data['Title']= all_data['Name'].str.split(', ', expand=True)[1].str.split('.', expand=True)[0] Can anyone explain what is the meaning of this line of code?

Object of class stdClass could not be converted to string error

I have the following string: {"Coords":[{"Accuracy":"65","Latitude":"53.277720488429026","Longitude":"-9.012038778269686","Timestamp":"Fri Jul 05 2013 11:59:34

python if user input contains string

Very basic question. We have the code: a = input("how old are you") if a == string: do this if a == integer (a != string): do that Obviously it d

C++ - Split string by regex

I want to split std::string by regex. I have found some solutions on Stackoverflow, but most of them are splitting string by single space or using external lib

SQL Server convert select a column and convert it to a string

Is it possible to write a statement that selects a column from a table and converts the results to a string? Ideally I would want to have comma separated value

JavaScript equivalent of python string slicing

Is there a JavaScript equivalent to this Python method of string slicing? >>> 'stackoverflow'[1:] 'tackoverflow' I have tried: // this crashes console

First Not Repeating Character Code

Here is the question: Write a solution that only iterates over the string once and uses O(1) additional memory, since this is what you would be asked to do duri