Regular Expressions (Regex) Tutorial: How to Match Any Pattern of Text
Why Stack Overflow recommends it
Stack Overflow users link it as a beginner-friendly introduction when an answer or comment calls for regex and the asker has never used it.
Recommended by 5 people across 5 different months, 2015 to 2022.
What it is
A 38-minute language-agnostic tutorial by Corey Schafer that teaches regular expression syntax for matching patterns in text such as emails, phone numbers and URLs. It works through examples in a text editor and links to code snippets and a separate Python regex video.
What people said
Recommends Ooker · 2015-09 · Stack Overflow · on “How to remove empty lines with or without whitespace”
If you are not willing to try regex (which you should), you can use this: s.replace('\n\n','\n') Repeat this several times to make sure there is no blank line left. Or chaining the commands: s.replace('\n\n','\n').replace('\n\n','\n') Just to encourage you to use regex, here are two introductory videos that I find intuitive: • Regular Expressions (Regex) Tutorial [this video] • Python Tutorial: re Module [LINK]
Recommends Ali · 2018-11 · Stack Overflow · on “How to get versionName/versionCode from kotlin-dsl Gradle file in Gitlab ci script?”
I Read about Regex , and i find out how to do it. you should change the regex to get the versionName/versionCode because the way of assigning them changed. you should do it this way: - export VERSION_NAME=`egrep '[[:blank:]]*versionName[[:blank:]]?=[[:blank:]]?\"((\w|\.)+)\"' app/build.gradle.kts | awk '{print $3}'| sed s/\"//g` - export VERSION_CODE=`egrep '[[:blank:]]*versionCode[[:blank:]]?=[[:blank:]]?([0-9]+)' app/build.gradle.kts | awk '{print $3}'` if you want to learn about regex, i recommend you to see this [this video] video on youTube
Recommends nomore2step · 2019-12 · Stack Overflow · on “How to only allow the user to enter an input of a-z and using an if statement to prompt the correct input”
This sounds like the perfect time for a regex implementation. If you have never heard regex I recommend checking out this video [this video] . Essentially it is used to match patterns within a string. For java you could simply check whether each character is a lower case letter with: System.out.println("Please enter letters of the alphabet"); String input1 = scnObj.nextLine(); if (!input1.matches("[a-z]*") { System.out.println("Please try again."); } else { System.out.println("Correct."); } However it might have to add a little more if you want to allow for spaces/hyphens. Good luck!
Recommends John Szesnat · 2020-09 · Stack Overflow · on “Is there a way to parse out the computer name”
I really appreciate the help. Im watching this video [this video] but looking for more info. Like one for dummies. I understand most of this and testing it out. I like the problem solving aspect about it. Again many thanks and if you can point me into the right directions maybe i can be helping others here too
Recommends Matiiss · 2022-11 · Stack Overflow · on “how to extract words from the string in the list in python?”
@AnshumanSharma This tutorial on regex by Corey Schafer [this video] , this tutorial on `re` by Corey Schafer [LINK] , this HOWTO in the official docs [LINK] and just the documentation of `re` module [LINK] (includes explanation for each character and stuff), as well as [LINK] for practice, explanation and other stuff