Regular Expressions (Regex) Tutorial: How to Match Any Pattern of Text

///Regular Expressions (Regex) Tutorial: How to Match Any Pattern of Text

Regular Expressions (Regex) Tutorial: How to Match Any Pattern of Text

FavoriteLoadingAdd to favorites

In this regular expressions (regex) tutorial, we’re going to be learning how to match patterns of text. Regular expressions are extremely useful for matching common patterns of text such as email addresses, phone numbers, URLs, etc. Almost every programming language has a regular expression library, so learning regular expressions with not only help you with finding patterns in your text editors, but also you’ll be able to use these programming libraries to search for patterns programmatically as well. Let’s get started…

Java468x60

The code from this video can be found at:

Python Regex Tutorial:

✅ Support My Channel Through Patreon:

✅ Become a Channel Member:

✅ One-Time Contribution Through PayPal:

✅ Cryptocurrency Donations:
Bitcoin Wallet – 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet – 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet – MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey’s Public Amazon Wishlist

✅ Equipment I Use and Books I Recommend:

▶️ You Can Find Me On:
My Website –
My Second Channel –
Facebook –
Twitter –
Instagram –

source

By |2019-12-17T00:34:00+00:00December 17th, 2019|Java Video Tutorials|37 Comments

37 Comments

  1. M. Zaman SHARIATI December 17, 2019 at 12:34 am - Reply

    How to count /write regex for 01 in a string of 00100010000100010010100001 for example?

  2. Fawad khan December 17, 2019 at 12:34 am - Reply

    Thank you, Your channel is worthy the whole youTube.

  3. Zhuolun Du December 17, 2019 at 12:34 am - Reply

    Thank you so much😭

  4. Dewank Pant December 17, 2019 at 12:34 am - Reply

    amazing video, well for some reason when I tried using bHa regex search in atom editor on the same text (Ha HaHa) it gives me 3 results basically it's taking all three Ha. Everything else is working exactly as you mentioned except for this one case. Can you please help. Here is a screenshot of what is happening https://imgur.com/a/9hqnCEw

  5. Shabbir Saifee December 17, 2019 at 12:34 am - Reply

    Thank you Corey 🙂

  6. Mirco Mares December 17, 2019 at 12:34 am - Reply

    how to select only the first MR?

  7. Sathvik Joel December 17, 2019 at 12:34 am - Reply

    Great Explanation.!! And please do make some video on advanced Regex, Eagerly waiting for it.

  8. Dima G December 17, 2019 at 12:34 am - Reply

    I finally get the REGEXP. Great job!

  9. Simon Liljestrand December 17, 2019 at 12:34 am - Reply

    Absolutely wonderful tutorial! Thank you!

  10. sandeep reddy December 17, 2019 at 12:34 am - Reply

    Great teaching skills.

  11. sudhakar D December 17, 2019 at 12:34 am - Reply

    How to validate the below
    Allow dot and hyphen any number of times, but they shouldn't be next to each other.

    Ex: abc—————-d……..sdfdsf———-df…….. ——> Accepted
    abcd………..- —-> Shouldn't Accept [as dot and hyphen are next to each other]
    abcd——-. —–> Shouldn't Accept [as dot and hyphen are next to each other]

  12. Rct Marcel December 17, 2019 at 12:34 am - Reply

    How do I do a find ^l (soft returns) and replace with ^p (hard returns) using RegEx?

  13. Emmanuel Ogunwede December 17, 2019 at 12:34 am - Reply

    finally i find regex ridiculously simple!!!! this is awesome

  14. jones tako December 17, 2019 at 12:34 am - Reply

    thanks

  15. Eric Nguyen December 17, 2019 at 12:34 am - Reply

    Best tutorial so far. Thanks

  16. Ahmed yousry December 17, 2019 at 12:34 am - Reply

    seriously you are a great teacher, thank you so much, it is so helpful

  17. Паша Семикин December 17, 2019 at 12:34 am - Reply

    Thank for the lesson

  18. Madan M Devaiah December 17, 2019 at 12:34 am - Reply

    Just when I thought I will give up on RegEx! This is GOLD 🙂

  19. Sean C. December 17, 2019 at 12:34 am - Reply

    Nice job! I learned this in college with a much worse explanation and love the way you presented the concept 👍🏼

  20. richard90153 December 17, 2019 at 12:34 am - Reply

    Thank you Sir! Been stuck on this subject for days. This really helped bring together my reading materials.

  21. Peter Onger December 17, 2019 at 12:34 am - Reply

    Thank you for this video.
    Is very Useful.

    13:20 – Why you not use pipe?
    ddd[.|-]ddd[.|-]dddd
    Edit – oh, in [] is not need.
    ok

    24:02 – why not work (r|s|rs) for me correctly in google sheets?
    A1=Mr. Schafer
    =regexextract(A1;"M(r|s|rs).?s[A-Z]w*")
    Output=r

    28:36 – Is this beter for email?
    [a-zA-Z0-9_.+-]+@[a-zA-Z0-9.-]+.[a-zA-Z0-9.-]+
    I add dot for subdomains.

    32:43 – what if somebody write http://wWw.example.com ? wWw and no protocol?

    32:59 – hey w include "_" and this "_" is not allowed in domain name!
    In top level domains is also not allowed "_".
    Is this better?
    (https?://)?[wW]{3}?.?[a-ZA-Z0-9.-]+.[a-zA-Z.-]+

  22. Sachin Artani December 17, 2019 at 12:34 am - Reply

    Really worth to watch it 👌👌

  23. shubham sharma December 17, 2019 at 12:34 am - Reply

    https://youtu.be/sa-TUpSx1JA?t=830 allows `223-123.1234` . Is there a way we can make sure that at a given time only `-` or a `.` is used? Obviously there's a hacky way ^(d{3}.d{3}.d{4})|d{3}-d{3}-d{4}$ Just wondering if there is some in built feature in regex to support it?

  24. Ricardo Perez December 17, 2019 at 12:34 am - Reply

    you by. best men thankc from dominican republic

  25. WildRover1964 December 17, 2019 at 12:34 am - Reply

    seems quite simple the way you present it.

  26. Evolution_Algorithm December 17, 2019 at 12:34 am - Reply

    For Pycharm users you can try Regex search string by just having a file open, then press Ctrl+F for find, and in the find box there are check boxes for Regex and match case. Also, if you click the blue question mark next to the Regex check box it opens up a window showing you Regex search characters and what they search for.

  27. Evolution_Algorithm December 17, 2019 at 12:34 am - Reply

    You can put a b for a word boundary at the end of the name search string like "M(r|s|rs).?s[A-Z]w*b".

  28. Junaid Khan December 17, 2019 at 12:34 am - Reply

    Omg….this was supposed to be difficult. U are awsome❤️

  29. Phythorio December 17, 2019 at 12:34 am - Reply

    I dunno why I ignored this vid awhile ago, but this is worth watching. 100/10 ⭐⭐⭐.
    Keep it up 👍

  30. Bea bL December 17, 2019 at 12:34 am - Reply

    ım just wonder why everybody love this video

  31. Stefan Wagner December 17, 2019 at 12:34 am - Reply

    Why you don't want to write a valid regex for email adresses: https://stackoverflow.com/questions/201323/how-to-validate-an-email-address-using-a-regular-expression?page=1&tab=votes#tab-top and hopefully not an invalid one

  32. CJ December 17, 2019 at 12:34 am - Reply

    Very good tutorial, Thanks !

  33. Glenn Langford December 17, 2019 at 12:34 am - Reply

    Excellent, thanks Corey

  34. Bhaskar Banepali December 17, 2019 at 12:34 am - Reply

    hello, can you help me on this one.

    in the given text like this

    "My name is person_namenn"

    how can I escape in the regular expression the beginning " and the ending " as well as escape n?

    thank you,

  35. Sampelmind81 December 17, 2019 at 12:34 am - Reply

    Hello from Germany! Is there a way to search for a single keyword in a hole sentence? Thank you!

  36. Loren ZERO December 17, 2019 at 12:34 am - Reply

    Thanks for sharing this superb tutorial. It really helped me a lot. I'll sure be sharing this to my friends.

  37. It'sR4yd December 17, 2019 at 12:34 am - Reply

    So now it's 2 am and I know regular expressions

Leave A Comment

*