To get the substring value from a specified string, we can use JavaScript substring() method.
This method will return a part of string based on start and end point parameter value.
Syntax: substring (startPosition, endPosition);
StartPosition: This is mandatory parameter, mention start point value, from where you get sub string value.
EndPosition: This is optional, if you don’t specify, it will return the rest of string.
Check Below Example to Extract a Substring out of a String:
1 2 3 4 5 6 7 |
<script> $(document).ready(function(){ var StrVal = "Hope you got the solution. Good luck"; var subStrPart = StrVal.substring(5, 25); alert(subStrPart); }); </script> |