Tag: substring

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