Replace Line Breaks in a String C#

How can I replace Line Breaks within a string in C#?

Highlight the difference between two strings in PHP

What is the easiest way to highlight the difference between two strings in PHP? I'm thinking along the lines of the Stack Overflow edit history page, where new text is in green and removed text is...

Verifying that a string contains only letters in C#

I have an input string and I want to verify that it contains: Only letters or Only letters and numbers or Only letters, numbers or underscore To clarify, I have 3 different cases in the code,...

Quickest way (performance-wise) to turn a string into a byte[] array in C# using the ASCII character encoding

What's the fastest way to turn a string into a byte[] array in C#? I'm sending tonnes of string data through sockets and need to optimize every single operation. Currently I transform the...

Query string length limit in vba?

I am trying to combine multiple audit tables, and then filter the results into an excel sheet. The Union All and parameters make the query in excess of 1200 characters. It appears the string is...

How to Convert Boolean to String

I have a Boolean variable which I want to convert to a string: $res = true; I need the converted value to be of the format: "true" "false", not "0" "1" $converted_res = "true"; $converted_res =...

Set running time limit on a method in java

I have a method that returns a String. Is it possible that after a certain time, if threshold is excedeed for that method, to return some specific string?

Shorten string without cutting words in JavaScript

I'm not very good with string manipulation in JavaScript, and I was wondering how you would go about shortening a string without cutting any word off. I know how to use substring, but not indexOf...

How to find if an array contains a specific string in JavaScript/jQuery?

Can someone tell me how to detect if "specialword" appears in an array? Example: categories: [ "specialword" "word1" "word2" ]

How to replace uppercase with underscore?

I'm new to Python and I am trying to replace all uppercase-letters within a word to underscores, for example: ThisIsAGoodExample should become this_is_a_good_example Any...

'str' object does not support item assignment

I would like to read some characters from a string s1 and put it into another string s2. However, assigning to s2[j] gives an error: s2[j] = s1[i] # TypeError: 'str' object does not support item...

Finding all indexes of a specified character within a string

For example, if I had "scissors" in variable and wanted to know the position of all occurrences of the letter "s", it should print out 1, 4, 5, 8. How can I do this in JavaScript in most efficient...

Get first and rest of string from comma separated values in Javascript

Given a string like this: "boy, girl, dog, cat" What would be a good way to get the first word and the rest of them, so I could have this: var first_word = "boy"; var rest = "girl, dog,...

Best way to convert list to comma separated string in java

I have Set<String> result & would like to convert it to comma separated string. My approach would be as shown below, but looking for other opinion as well. List<String> slist = new...

Conveniently Declaring Compile-Time Strings in C++

Being able to create and manipulate strings during compile-time in C++ has several useful applications. Although it is possible to create compile-time strings in C++, the process is very...

extract part of a string using bash/cut/split

I have a string like this: /var/cpanel/users/joebloggs:DNS9=domain.com I need to extract the username (joebloggs) from this string and store it in a variable. The format of the string will...

How do I reverse a String in Dart?

I have a String, and I would like to reverse it. For example, I am writing an AngularDart filter that reverses a string. It's just for demonstration purposes, but it made me wonder how I would...

Search a file in linux and jump to position of the first find

I need help with a linux command with which I can search for a string in a text file and go to the first position this string is found and being able to scroll down and up from there. I am looking...

Differences between \W, \\W, [^a-zA-Z0-9_] in regular expression

I am trying to find all characters, which are not letters(upper/lowercase), numbers, and underscore, and remove it. stringA.replaceAll("[^a-zA-Z0-9_]","") // works perfectly fine However, the...

How to convert a string to an array in Golang?

How to convert a string to an array of strings with one element (i.e. that string) in Go effectively. For example: var s string s = "This is a string" to ["This is a string"] Obviously, one...

How to substring a string Python from a specific index in Python?

what is the best way to substring a string in Python starting from a specific character ? For example, if val = "s2*20", how to get the substring of val which is after *. The result should be res...

Python : Increase a string

I am not really familiar with Python yet. I have a string like "11223300". Now I want to increase the last byte of that string ( from "00" to "FF"). I tried to convert the string into an integer (...

How to concatenate all (string) values in a given pandas dataframe row to one string?

I have a pandas dataframe that looks like this: 0 1 2 3 4 0 I want to join strings 1 But only in row ...

Rotate a string with JavaScript?

I have a lot of the basics down, but I'm going through w3resource sample problems (https://www.w3resource.com/javascript-exercises/javascript-basic-exercises.php - question 5) and I'm really...

I'm trying to perform some manual encoding of strings using python

Probelm Description: sms_encoding() which accepts a sentence and converts it into an abbreviated sentence to be sent as SMS and returns the abbreviated sentence. Rules are as follows: a. Spaces...

Typescript: Enforce a type to be "string literal" and not <string>

Problem Is there a way in Typescript to define a type that is only a string literal, excluding string itself? Note that I am not talking about a certain list of string literal; for which, a simple...

how shall i call out this function using string format method?

i'm learning Python and have began with Google's Python Automation Beginner course. Idk if i chose it right but im already in week 4 and now have started facing confusion. Fill in the gaps in the...

Stretching a string to number of characters [Python]

Let's say a have list/string that looks like this - a = 'erik ffffffffff f f f f f '. By b = a.split(), I can get a list with the specific "words". The total number of characters in this list is...

replacing a substring in a string: Python

I am trying to continuously replace the substrings within a string based on user input but my string.replace syntax seems to replace the whole string with the substring from user input. here is...

discord.py: How to get the first letter of a user's name?

I want to make a "ticket-system" and want the channel it creates to have the name of the first letter of the user. So, I already have this: @client.event async def...

Relevant tags