- startsWith() and endsWith() method
- search() method
- indexOf() method
- substring() method
- substr() method
- slice() method
Let’s consider a string
str = "Welcome to GEEKS FOR GEEKS!!!". Now we have to find whether the string str starts with
startword = "Welcome" and ends with
endword = "!!!".
search() method: It checks whether a particular string is contained in another string and returns the starting index of that substring.
indexOf() method: As the name suggests, it finds the starting index of a substring in the string.
substring() method: It returns a string present between start and end index.
substr() method: It is similar to substring() method but takes start index and length of substring as parameters.
slice() method: This method returns the slices of string between any two indices in a string.
Let’s take an example of text in h1 element and check whether it starts and ends with the given substring.
- How to get text of specific option tag using jQuery?
- How to find element with specific ID using jQuery ?
- How to reload page after specific seconds in jQuery ?
- How to select all elements that contains some specific CSS property using jQuery ?
- How to remove specific value from array using jQuery ?
- How to scroll to specific element using jQuery ?
- Removing occurrences of a specific character from end of a string in PHP
- jQuery | jQuery.fx.interval Property with example
- jQuery | jQuery.fx.off Property
- jQuery | jQuery.support Property
- jQuery | jquery Property
- Domain Specific Tools
- Why overriding both the global new operator and the class-specific operator is not ambiguous?
- How to get specific number of child elements using CSS?
- How to adjust CSS for specific zoom level?
- How to position a div at specific coordinates ?
- How to determine if an array contains a specific value in PHP?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.