Tag: string

58 votes
30 answers
1.6K views
Get nth character of a string in Swift programming language

How can I get the nth character of a string? I tried bracket([]) accessor with no luck. var string = "Hello,

avatar
Corrin
0 1 0 9
asked 07 September, 2021
54 votes
22 answers
1.6K views
Any way to replace characters on Swift String?

I am looking for a way to replace characters in a Swift String. Example: "This is my string" I would like to

avatar
Freida
0 1 0 9
asked 07 September, 2021
55 votes
6 answers
1.3K views
Why are emoji characters like ?‍?‍?‍? treated so strangely in Swift strings?

The character ?‍?‍?‍? (family with two women, one girl, and one boy) is encoded as such: U+1F469 WOMAN,

avatar
Joseph
0 1 0 9
asked 07 September, 2021
61 votes
30 answers
2K views
How to enumerate an enum with String type?

enum Suit: String { case spades = "♠" case hearts = "♥" case diamonds = "♦" case clubs =

avatar
Dorian
0 1 0 9
asked 07 September, 2021
56 votes
27 answers
2.7K views
How do I check if a string contains another string in Swift?

In Objective-C the code to check for a substring in an NSString is: NSString *string = @"hello Swift"; NSRan

avatar
Alphonso
0 1 0 9
asked 07 September, 2021
63 votes
23 answers
436 views
Convert Int to String in Swift

I'm trying to work out how to cast an Int into a String in Swift. I figure out a workaround, using NSNum

avatar
Deedee
0 1 0 9
asked 07 September, 2021
58 votes
30 answers
1.9K views
Split a String into an array in Swift?

Say I have a string here: var fullName: String = "First Last" I want to split the string base on white spac

avatar
Sena
0 1 0 9
asked 07 September, 2021
61 votes
30 answers
2.5K views
Get the length of a String

How do you get the length of a String? For example, I have a variable defined like: var test1: String = "Scot

avatar
Forrest
0 1 0 9
asked 07 September, 2021
55 votes
24 answers
2.1K views
How to get GET (query string) variables in Express.js on Node.js?

Can we get the variables in the query string in Node.js just like we get them in $_GET in PHP? I know that in

avatar
Tana
0 1 0 9
asked 07 September, 2021
60 votes
21 answers
498 views
Convert bytes to a string

I'm using this code to get standard output from an external program: >>> from subprocess import

avatar
Keith
0 1 0 9
asked 07 September, 2021
67 votes
30 answers
890 views
How to concatenate text from multiple rows into a single text string in SQL Server

Consider a database table holding names, with three rows: Peter Paul Mary Is there an easy way to turn this i

avatar
Xavier
0 1 0 9
asked 07 September, 2021
59 votes
7 answers
2.1K views
Ukkonen's suffix tree algorithm in plain English

I feel a bit thick at this point. I've spent days trying to fully wrap my head around suffix tree constru

avatar
Wilber
0 1 0 9
asked 07 September, 2021
55 votes
1 answers
2.5K views
Initializing the string in C; Is the following useful?

I know how to initialize strings in C in two different ways. char str[] = "abcd"; char str[] = {'a'

avatar
Freida
0 1 0 9
asked 07 September, 2021
60 votes
30 answers
519 views
How can I convert a stack trace to a string?

What is the easiest way to convert the result of Throwable.getStackTrace() to a string that depicts the stackt

avatar
Lashawna
0 1 0 9
asked 07 September, 2021
60 votes
30 answers
684 views
How do I create a Java string from the contents of a file?

I've been using the idiom below for some time now. And it seems to be the most wide-spread, at least on t

avatar
Vi
0 1 0 9
asked 07 September, 2021
56 votes
30 answers
2K views
Difference between StringBuilder and StringBuffer

What is the main difference between StringBuffer and StringBuilder? Is there any performance issues when decid

avatar
Santiago
0 1 0 9
asked 07 September, 2021
51 votes
30 answers
1.1K views
How to split a string in Java

I have a string, "004-034556", that I want to split into two strings: string1="004"; string2="034556"; That

avatar
Brianne
0 1 0 9
asked 07 September, 2021
54 votes
15 answers
2.8K views
Why does this code using random strings print "hello world"?

The following print statement would print "hello world". Could anyone explain this? System.out.println(random

avatar
Carmelina
0 1 0 9
asked 07 September, 2021
63 votes
30 answers
2.2K views
How to generate a random alpha-numeric string

I've been looking for a simple Java algorithm to generate a pseudo-random alpha-numeric string. In my si

avatar
Arline
0 1 0 9
asked 07 September, 2021