Powered by Blogger.

Saturday, October 28, 2017

How to retrieve substring between two words using jQuery in asp.net?



In this post we will discuss how we can retrieve sub string between two words using jQuery in asp.net.

Here let us do inside an asp.net page.

Also you can read:
- Method Overloading in C#.Net

- Convert first letter to uppercase in C#.Net

- Get all time zones in C#.Net

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnGetString").on("click", function () {
                var mainString = "This was method to retrieve sub string between two string here.";
                var subString = mainString.match("was(.*)here");
                alert(subString[1]);
            });
        });
    </script>
    <br />
    <div class="row">
        <div class="col-md-4">
            <input type="button" id="btnGetString" value="Get sub string between words" /><br />
        </div>

    </div>

Once you click on the button, you can see the sub string like below:

retrieve substring between two words jQuery asp.net






0 comments

Post a Comment