REGEX Tutorial Regular Expressions

Derek Banas · 377K views · 2010 · 11:54

Open on YouTube

Python, Ruby & scripting languagesEducation & learningtutorial

Why Stack Overflow recommends it

Stack Overflow users link it when answering PHP, Python and Delphi questions where the asker needs a quick, approachable introduction to regular expressions.

Recommended by 4 people across 4 different months, 2011 to 2017.

What it is

A roughly 12-minute screencast tutorial by Derek Banas that walks through regular expression syntax and the codes used to build patterns. It aims to teach viewers how to use regexes in practice, independent of any single language.

What people said

Strong rec Gabriel Lupu · 2013-01 · Stack Overflow · on “PHP+javascript Input URL parsing”

I also had that "irrational fear of regex" :). I can recommend you some material to understand them once for all, very well explained on youtube : [this video] . There are 3 parts. I recommend all of them! Good luck!

Recommends Morgan Delaney · 2011-09 · Stack Overflow · on “PHP make links using preg_replace?”

echo preg_replace("#(^|[\n ])(([\w]+?://[\w\#$%&~.\-;:=,?@\[\]+]*)(/[\w\#$%&~/.\-;:=,?@\[\]+]*)?)#is", "\\1<a href=\"\\2\" title=\"\\2\" rel=\"nofollow\">\\2</a>", $string); I would consider this a complicated Regular Expression. However, if you're interested in learning more, I really liked getting started with this video [this video]

Recommends hillmandj · 2013-03 · Stack Overflow · on “python search and replace”

I would consider using RegEx (the re module in Python). This would allow you to create functions that could search for specific text patterns. You could extract select "groups" of text using the group() function if you properly construct your re.compile() function and re.search() function. The library is quite extensive, so here is a link to the documentation: [LINK] I would also check out an online tutorial, such as this one: [this video]

Recommends Coolq B · 2017-05 · Stack Overflow · on “Best way to parse a file Python”

Here's my answer using regex: import re text = """<REAPER_PROJECT 0.1 "4.731/x64" 1431724762 RIPPLE 0 RECORD_PATH "Audio" "" <RECORD_CFG ZXZhdxgA > <APPLYFX_CFG > LOCK 1 <METRONOME 6 2 VOL 0.25 0.125 FREQ 800 1600 1 BEATLEN 4 SAMPLES "" "" > > """ print(re.sub("LOCK 1\D", "LOCK 0" + "\n", text)) If you're interested in writing the file to disk. with open("written.txt", 'w') as f: f.write(re.sub("LOCK 1\D", "LOCK 0" + "\n", text)) EDIT You said that you wanted it to be more flexible? Okay, I tried to make an example, however for that I would need more information about your setup..etc. So instead, I'll point you to a resource that could help you. This will also be good, if you ever want to ch

Cites Victor · 2011-11 · Stack Overflow · on “Regex a source code file”

I have a text that is a source-code file, I need to find the first parameter of all calls of this function. That can be called in this 2 ways. I'm completely dumb in regex. lang('FOUND') and lang('FOUND',[loremipsum]) FOUND should be anything, is this value that I'm searching. I will execute the Regexp in delphi, but I think regular expression is language independent EDIT Using the @Ken White answer and this Video [this video] I did this code, and works fine! Regular expression: (?:lang\s*\(\s*')(.*?)(?:'\s*\)|'\s*\,\s*\[.*\]\s*\)) Include the Unit PerlRegEx [LINK] on Uses procedure TForm1.Button1Click(Sender: TObject); var Regex: TPerlRegEx; begin Regex := TPerlRegEx.Create(); Regex.RegEx := '(?