What do you want to save?
Add Code snippet
New code examples
-
C++ 2021-10-13 05:35:11
Write a function called clean that takes a C++ string as input and removes any characters in the string that are not letters except for space blanks.
// ALWAYS USE PASS BY REFERENCE WITH STRINGS AND VECTORS. void clean ( string & str) { for ( int i = 0; i < str.length(); i++ ) { if (str[i] != ' ' && (str[i] < 'A' || (str[i] > 'Z' && str[i] < 'a') || str[... Add solution -
Javascript 2021-10-13 04:42:08
find single quote and replace in javascript
function replaceAll(str, find, replace) { var escapedFind=find.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); return str.replace(new RegExp(escapedFind, 'g'), replace); } //usage example var sentence="How many shots did Bill t... Add solution -
Javascript 2021-10-12 22:26:10
javascript count number of times character appears in string
You could remove any other character in the string and check the length: str.replace(/[^aA]/g, "").length Here it is counted how many as are in str. The RegExp is described below: [ // Start Character Group ^ // Not operator in character group... Add solution -
Javascript 2021-10-12 07:54:03
javascript replace \n
function nl2br(str){ return str.replace(/(?:\r\n|\r|\n)/g, '<br>'); } var stringWithNewLines= `Well this is a a very broken sentance`; var stringWithBrs=nl2br(stringWithNewLines); // stringWithBrs= "Well this is a<br>a very <br... Add solution -
C# 2021-10-12 04:32:04
c# + max char frequency in string
//return the character that appears the maximum number of times in the string //contain only ASCII characters, from the ranges ('a'-'z','A'-'Z','0'-'9'), and case sensitive //If there is a tie in the maximum number of times a character appears in the stri... Add solution -
Javascript 2021-10-11 10:27:04
javascript remove all spaces from string
str = str.replace(/\s/g, ''); Add solution -
Java 2021-10-09 18:13:06
Java program to delete vowels in a given string
// Java program to delete vowels in a given string import java.util.*; public class RemoveVowelsInString { public static void main(String[] args) { String str = "Deekshit Prasad"; System.out.println("Given string: " +... Add solution -
-
Javascript 2021-10-09 09:34:05
regex for anything but quoted strings site:stackoverflow.com
var rgx = /(\B(".+?")\B|\B('.+?')\B|\B(`.+?`)\B)/g; var str = `"Lorem ipsum dolor sit amet", consectetur adipisicing elit, "'sed do eiusmod tempor,'" incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, \`qu... Add solution
Best helpers
Ranking is empty