![]() ![]() ![]() We can achieve this by using a Regular Expression which provides us the text search functionality with its string method: search(). How to find a position of a particular word or a substring in the given string? Var incStr = strng.includes("human", 38) Strng = 'Either way, time largely defines the human experience.' Ĭase 2 - Starting Point of search is after ‘h’ in the word “human” Strng = "Either way, time largely defines the human experience." ĭocument.write("Is 'human' present in the string? : " + incStr) Ĭase 1 - Starting Point of the search is before ‘h’ in the word “human” Note: includes() method is not supported in IE11 Also, it has got the flexibility to identify the starting position of the search. If the word or substring is present in the given string, the includes() method returns true otherwise, it returns false. In this case, we will use the includes() method which determines whether a string contains the specified word or a substring. ![]() How to find if a word or a substring is present in the given string?
0 Comments
Leave a Reply. |