Tag: substr

54 votes
22 answers
3K views
Extract substring in Bash

Given a filename in the form someletters_12345_moreleters.ext, I want to extract the 5 digits and put them int

avatar
Wilber
0 1 0 9
asked 07 September, 2021
51 votes
26 answers
2K views
How to check if a string contains a substring in Bash

I have a string in Bash: string="My string" How can I test if it contains another string? if [ $string ?? &ap

avatar
Sena
0 1 0 9
asked 07 September, 2021
51 votes
4 answers
2.5K views
Using PHP's substr() with special characters at the end results in question marks

When I use the substr() function in PHP, I get an question mark (a square with a question mark - depending on

avatar
Joseph
0 1 0 9
asked 07 September, 2021
63 votes
23 answers
2.2K views
How do I check if a string contains another string in Objective-C?

How can I check if a string (NSString) contains another smaller string? I was hoping for something like: NSS

avatar
Thurman
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