Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; COUNT_CLASS has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/functions.php on line 1713

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; sidebar_generator has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/plugins/multiple_sidebars.php on line 29

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_video_widgets has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/video.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_soundcloud has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/soundcloud.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_counter_widget has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/social-counter.php on line 9

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_news_in_pic has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/new-in-pic.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Flickr_Widget has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/flickr.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_fb_likebox has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/fb.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_google_follow has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/google-follow.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_popular has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/popular-posts.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_recent_posts has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/recent-posts.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_cate_posts has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/category-posts.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; tabs_widget has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/tabs.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_youtube_widget has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/youtube-subscribe.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_social_links has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/social-links.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_comments_widget has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/comments.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_author_bio has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/bio-author.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_login has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/login.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_search_widget has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/search.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Ad_120_600_Widget has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/ads120.php on line 7

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Ad_125_125_Widget has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/ads125.php on line 7

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Ad_250_250_Widget has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/ads250.php on line 7

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Ad_300_300_Widget has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/ads300.php on line 7

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_tweets_load has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/twittes.php on line 10

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; feedburner_widget has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/newsletter.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_related has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/related.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_slider has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/slider.php on line 6

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bd_top_rate has a deprecated constructor in /var/www/vhosts/eduardoarellano.com/d4mations.com/wp-content/themes/renad/includes/widgets/top-review.php on line 6
Using regular expressions in JavaScript | D4mations.com
  • Thursday , 25 April 2019

Using regular expressions in JavaScript

Code Canyon



Link for all dot net and sql server video tutorial playlists
http://www.youtube.com/user/kudvenkat/playlists

Link for slides, code samples and text version of the video
http://csharp-video-tutorials.blogspot.com/2015/01/using-regular-expressions-in-javascript.html

What is a Regular Expression
A regular expression is a sequence of characters that forms a search pattern.

Let us understand the use of regular expressions with an example. The following strings contain words and numbers. From the string we want to extract all the numbers. Bsically the program should work with any string.

Mark-9 Tim-890 Sam-10 Sara-9902
Result : 9, 890, 10, 9902

908ABC12XYZ34
Result : 908, 12, 34

$1 $2 $901 ABC(100)
Result : 1, 2, 901, 100

Here is what we want the page to do
1. User enters the string in the first textbox
2. When “Process String” button is clicked, the numbers should be extracted from the string and displayed in the text area element.

It will be very complex and error prone if we have to achieve this without using regular expressions.

[input type=”text” id=”txtBox” style=”width:250px” /] [br /][br /] [input type=”button” value=”Process String” onclick=”processString()” style=”width:250px” /] [br /][br /] [textarea id=”txtArea” rows=”4″ cols=”30″][/textarea] [script type=”text/javascript”] function processString()
{
// Clear the textarea element
document.getElementById(“txtArea”).value = “”;
// Retrieve the user intput from the textbox
var inputString = document.getElementById(“txtBox”).value;
// Regular expression should be in 2 forward slashes //
// Letter g at the end of the regular expression performs a global match
// match() method returns all substrings that match the given regular expression
var result = inputString.match(/d+/g);

if (result != null) {
// Add the retrieved numbers to the textarea element
for (var i = 0; i [ result.length; i++) {
document.getElementById(“txtArea”).value += result[i] + “rn”;
}
}
}
[/script]
Original source

3d Ocean

Related Posts

23 Comments

  1. krutomjer
    April 12, 2019 at 16:47

    You have the best tutorials on internet, by far. I am so thankful to you, I got my first job due to your SQL tutorials, second job due to your C# tutorials and now I'm using this on my third job. Thank you very much sir.

  2. skullmate 101
    April 12, 2019 at 16:47

    Ur voice is soo fucking annoying!!!

  3. Dawid Dahl
    April 12, 2019 at 16:47

    Thank you!

  4. Fernando Diaz
    April 12, 2019 at 16:47

    you're the best in the world!! 😀

  5. Shiva Podiyal
    April 12, 2019 at 16:47

    Thanks Broh

  6. n o
    April 12, 2019 at 16:47

    This was immensely helpful, thank you. Keep up the good work

  7. Chris Osman
    April 12, 2019 at 16:47

    I find it easier to accomplish what regular expressions do without using them. That's just me.

  8. Fun With Benefits
    April 12, 2019 at 16:47

    emails ending in .com,.net, .org, .co, .me please help me dude

  9. Zen Logie
    April 12, 2019 at 16:47

    I wish there were more instructors like you on youtube dear sir. All my respect!

  10. Sourabh Kulkarni
    April 12, 2019 at 16:47

    one of the best tutorial on regular expression. god bless you.

  11. Error 404
    April 12, 2019 at 16:47

    Superb!
    1️⃣

  12. abhijeet gupta
    April 12, 2019 at 16:47

    Great video

  13. Triveni Triveni
    April 12, 2019 at 16:47

    nice but speak in telugu plz i can"t understand

  14. Elkhan Hamet
    April 12, 2019 at 16:47

    Amazing tutorial sir!!! Thank you very much for your help!!!

  15. No Name
    April 12, 2019 at 16:47

    You don't need to add this line document.getElementById("txtArea").value = ""; . Just write like this document.getElementById("txtArea").value = result[i] + "rn"; without +

  16. Shaik Arshad
    April 12, 2019 at 16:47

    Awesome teaching…….try to have php vedio in your chanel…!

  17. joe smith
    April 12, 2019 at 16:47

    AND THAT MY FRIENDS IS WHY I USE PROCESSING AND NOT JSCRIPT OR ORACLE JAVA! SEARCH PATTER HA SEARCH PATTERN IS THE DIRECTIONS A PLANE OR A DIVER OR ABOAT TAKES TO FIND SOMETHING ! REALLY BAD ANALOGY ! REGEX SEARCHES A PAGE FOR CHARACTERS U WANT TO FIND. LIKE A WORD SEARCH !

  18. Fabian Madurai
    April 12, 2019 at 16:47

    Hello from South Africa. Your videos are excellent. Better than any video tutorials I have watched. I love that you build up your explanation from start to finish. Thank you very much for your contributions.

  19. Pancakes Mister
    April 12, 2019 at 16:47

    Thank you for your video! You rule! Thumps up!

  20. Garrett Baker
    April 12, 2019 at 16:47

    Excellent series…very helpful! Thanks!

  21. Sam Dave Pollard
    April 12, 2019 at 16:47

    This was very helpful.
    Thank You for sharing your knowledge.

  22. Abraham Ban
    April 12, 2019 at 16:47

    is there a cheat sheet of all reg exp?

  23. For Phone
    April 12, 2019 at 16:47

    It was so clear man!! TY GREAT!!

Leave A Comment

You must be logged in to post a comment.