New answers tagged string
Advice
2
votes
0
replies
0
views
Input: "ab1000cd25000ef30" Output: [10, 25, 30]
What have you tried? What specifically do you need help with?
0
votes
Does String.ToLower() always allocate memory?
Tangentially related, but RegEx.Replace() has a similar behavior. You get a new string object even if it's unchanged from the original.
Take the common case of whitespace normalization. You want ...
0
votes
Create a String from each line, adding quote marks, from text file, In Java
Modern Java
We can make simple work of this by using the features of Modern Java: NIO.2, streams, lambdas, and IO class.
Path.of identifies the file to read, in Java 11+.
Files.readAllLines in Java 8+ ...
2
votes
Accepted
VBA/Regex replace characters with groups using pattern
I fixed your macro, try it
Your regex was perfect! You just needed to add cell.NumberFormat = "@" before assigning the new value. Without it, Excel reconverts "7:30AM" back to time ...
0
votes
How to check that a string is an int, but not a double, etc.?
Another option is to check if a cast is reversible.
function is_int_like(string $value): bool {
return (string) (int) $value === $value;
}
or, if the value could be int|string:
function is_int_like(...
-1
votes
Convert list of objects to string in one line
Here is the shorter version I've ever used:
var result = string.Join(",", [.. objestsList.Select(x => x.stringValue)]);
Advice
0
votes
0
replies
0
views
Best SQL Function for Text Filtering
This really depends.
If this is just about soccer, because you always want to quickly find all soccer content, then a function index might already be the perfect solution.
As this is about people's ...
Advice
0
votes
0
replies
0
views
Best SQL Function for Text Filtering
Like others say, you can use LIKE on your column, but CONTAINS_SUBSTR is a better choice because this function is optimized for performance when working with large datasets. Remember that this ...
Advice
0
votes
0
replies
0
views
Best SQL Function for Text Filtering
Many databases support "full text search" beyond the LIKE operator. For example postgress
Advice
0
votes
0
replies
0
views
Best SQL Function for Text Filtering
You really need to show us the structure of your dataset and some sample data in order for us to accurately assist you.
Advice
0
votes
0
replies
0
views
Best SQL Function for Text Filtering
The best and simplest way to filter rows containing a specific word like "soccer" in SQL is to use the LIKE function.
Example:
SELECT *
FROM your_table
WHERE column_name LIKE '%soccer%';
...
2
votes
Accepted
Getting weird results from java string codepoints on a windows machine
Those ? are replacement characters. When encoding, replacement characters are used for characters not supported by the charset. When decoding, replacement characters are used for byte subsequences the ...
2
votes
How do I check whether a string is zero-length in Meson?
This can be achieved by comparing the string to an empty string, e.g.:
if get_option('example') != ''
# do something if example isn't set to an empty string
endif
Advice
0
votes
0
replies
0
views
How to find a substring within a string in C?
Typically you would use strstr (or strcasestr if you want to ignore case).
Advice
1
vote
0
replies
0
views
How to find a substring within a string in C?
Just kidding! Don't use this approach!!
POSIX regex FTW
#include <regex.h>
#include <stdio.h>
#indlude <stdlib.h>
#define HAYSTACK "C is a programming language"
#define ...
Advice
2
votes
0
replies
0
views
How to find a substring within a string in C?
I don't know which browser or search engine you are using, but if i do a search using the term
How to find a substring within a string in C?
i receive the following AI response (in my browser with ...
Advice
0
votes
0
replies
0
views
How to find a substring within a string in C?
Don't forget to look at Check substring exists in a string in C and the many other variants of that question on StackOverflow. You have two main choices. Either use the string.h functions like strstr()...
Advice
0
votes
0
replies
0
views
How to find a substring within a string in C?
Thank you! This is very helpful for understanding how to do it without using libraries
Advice
0
votes
0
replies
0
views
How to find a substring within a string in C?
Thank you! This is exactly what i needed!
Advice
3
votes
0
replies
0
views
How to find a substring within a string in C?
The C function strstr() (from <string.h>) is exactly for that:
char* strstr( const char* str, const char* substr );
Finds the first occurrence of the null-terminated byte string pointed to by ...
Advice
0
votes
0
replies
0
views
How to find a substring within a string in C?
Find l (:the 1st char of word[]) in string[].
If found, then check if the next character in string[] equals a (:the 2nd char of word[]).
If equals, then ...
Best practices
0
votes
0
replies
0
views
Unescape string to get special character from user input
The shell (I assume Linux) interprets \n as just n. In order to pass in the actual newline, you have to escape it:
python -m service.run --separator $'\n'
0
votes
how to return a specific value if a substring (i.e., a word) is found in a cell which contains text in EXCEL
Using 365, with regular expression the below formula returns the corresponding values you need.
It eliminates substrings where a word contains a searched value and some other characters e.g. Nickels ...
0
votes
Converting a byte to a binary string in C#
I'm not sure if this is a recent change, but in 2026 -- rather than padding with zeroes -- you can use a formatting string passed to byte.ToString(), e.g.
var someByteValue = (byte)255;
Console.Write(...
0
votes
Regular expressions loop code, how Backtracking works?
If I understand you correctly then you're just missing an additional try-catch and the maxreps >= 0 or throw Backtracking;
before the next loop; otherwise you have an infinite loop, also you are ...
0
votes
Remove spaces from std::string in C++
std::erase_if since C++20
#include <cctype>
#include <cstdio>
#include <algorithm>
#include <string>
int main () {
std::string s{" Here Is Some Text With Spaces "...
1
vote
Toggle between two strings
To toggle between two strings, use ternary operator.
String other = value.equals("good") ? "bad" : "good"; // Toggles between two strings.
0
votes
Join strings with different last delimiter
Yes, this is a common requirement (often called joining with a different last delimiter). The standard Collectors.joining(", ") does not support this directly, but you can handle it cleanly ...
0
votes
Join strings with different last delimiter
As noted by @NarutoUzumaki in this answer, JDK 22 provides ListFormat which does this for lists with and/or in a locale-sensitive way (with or without the oxford comma).
In JDK SE 22 we have a ...
0
votes
Find row with longest string in R
Here is a dplyr option:
library(dplyr)
DF %>%
filter(nchar(V1) == max(nchar(V1)))
1
vote
How can I check if 2 columns have similar text in pyspark?
You can use probabilistic record linkage to find similarities between words, which will help link table columns. Also, if you are using Databricks, you can use Databricks ARC. This will find and link ...
2
votes
How can I generate random strings consisting of eight hex digits?
There's also the String::Random, which provides various ways to create strings passed on patterns, structure, or something else you might define:
use String::Random;
use v5.10;
use String::Random qw(...
1
vote
How can I generate random strings consisting of eight hex digits?
my $rand_hex = join '', map {[0..9,A..F]->[rand 16]} 1..8;
This will generate a string, not just a sequential print (as the method shown above). I'm not a grand master in Perl but for me this is ...
Top 50 recent answers are included
Related Tags
string × 184917java × 32715
python × 32568
arrays × 19111
regex × 16439
c++ × 16434
c# × 15705
c × 14279
javascript × 12382
php × 11550
list × 7099
split × 6959
replace × 6569
r × 5886
android × 5639
python-3.x × 5473
integer × 4416
char × 3914
substring × 3549
pandas × 3365
parsing × 3341
algorithm × 3284
sql × 3007
ruby × 2966
swift × 2893