Get the first occurrence of the specified string pattern in Julia – findfirst() Method
The findfirst() is an inbuilt function in julia that is used to return the first occurrence of the specified pattern in a specified string.
Syntax:
findfirst(Pattern::AbstractString, String::AbstractString)
Parameters:
- Pattern: Specified pattern to be searched
- String: Specified string
Returns: It returns a number in the format of First_number:Second_number. Where the first number is the first position of occurrence of the pattern in the specified string whereas the second number is the position in the string where the pattern ends.
Example 1:
Python
Println(findfirst( "g" , "geeks" ))
Println(findfirst( "eek" , "geeks" ))
Println(findfirst( "ks" , "geeks" ))
Println(findfirst( "geeks" , "geeksforgeeks" ))
|
Output:
Example 2:
Python
Println(findfirst( "4" , "2468" ))
Println(findfirst( "234" , "123456" ))
Println(findfirst( "45" , "123456" ))
|
Output:
Last Updated :
23 Feb, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...