SlideShare a Scribd company logo
RegularExpressions
Regular
Expressions
3
The Purpose of REX
• Regular expressions are the main way to match patterns
within strings or text. For example, finding pieces of text
within a larger document, or finding a rule within a code
sequence.
• There are 3 main methods that use REX:
1. matching (which returns TRUE if a match is found
and FALSE if no match is found.
2. search or substitution, which substitutes one pattern
of characters for another within a string
3. split, separates a string into a series of sub-strings
• REX are composed of chars, character classes, groups,
meta-characters, quantifiers, and assertions.
4
Imagine Literal Matching
5
Literal Matching 2
•
6
But don't end like this
7
Match Operator
• If you want to determine whether a string matches a
particular pattern, the basic syntax is:
Regex regex = new Regex(@"d+");
Match match = regex.Match("Regex 55 Telex");
if (match.Success) {
• Two important things here: "d+" is the regex. It means
“search the string for the pattern between the "" (d+
here). In the following we use standard Perl notation.
• Simple matching returns TRUE or FALSE.
8
Basic Quantifiers
• Quantifiers are placed after the character you want to match.
• * means 0 or more of the preceding character
• + means 1 or more
• ? Means 0 or 1
• For example:
my $str = “AACCGG”;
$str =~ /A+/; # matches AA
$str =~ /T+/; # no match
$str =~ /T*/; # matches 0 or more T’s
$str =~ /Q*/; # matches: 0 or more Q’s
• Matching positive or negative 23:
$str =~ /-?23/; # i.e. 0 or 1 – sign
9
More Quantifiers
• You can specify an exact number of repeats of a
character to match using curly braces:
$str = “doggggy”;
$str =~ /dog{4}y/; # matches 4 g’s
$str =~ /dog{3}y/; # no match
$str =~ /dog{3}/; # match--no trailing “y” in the pattern.
• You can also specify a range by separating a minimum
and maximum by a comma within curly braces:
$str =~ /dog{1,5}y/; # matches 1,2, 3, 4, or 5 g’s
• You can also specify a min. number of chars to match by
putting a comma after the minimum number:
$str =~ /dog{3,}; # matches 3 or more g’s
10
Grouping with Parentheses
• If you want to match a certain number of repeats of a
group of characters, you can group the characters within
parentheses. For ex., /(cat){3}/ matches 3 reps of “cat” in
a row: “catcatcat”. However, /cat{3}/ matches “ca”
followed by 3 t’s: “cattt”.
• Parentheses also invoke the pattern matching memory,
to say capturing.
11
Basic Meta-characters
• Some characters mean something other than the literal character.
• For example, “+” means “1 or more of the preceding character.
What if you want to match a literal plus sign? To do this, escape the
+ by putting a backslash in front of it: + will match a + sign, but
nothing else.
• To match a literal backslash, use 2 of them: .
• Another important meta-character: “.” matches any character. Thus,
/ATG…UGA/ would match ATG followed by 3 additional characters
of any type, followed by UGA.
• Note that /.*/ matches any string, even the empty string. It means: 0
or more of any character”.
• To match a literal period, escape it: .
• The “.” doesn’t match a newline.
• List of 12 chars that need to be escaped:  | / ( ) [ ] { } ^ $ * + ? .
12
Basic Assertions
• An assertion is a statement about the position of the match pattern within a
string.
• The most common assertions are “^”, which signifies the beginning of a
string, and “$”, which signifies the end of the string.
• Example:
my $str = “The dog”;
$str =~ /dog/; # matches
$str =~ /^dog/; # doesn’t work: “d” must be the first character
$str =~ /dog$/; # works: “g” is the last character
• Another common assertion: “b” signifies the beginning or end of a word.
For example:
$str = “There is a dog”;
$str =~ /The/ ; # matches
$str =~ /Theb/ ; # doesn’t match because the “e” isn’t at the end of the
word
13
Character Classes
• A character class is a way of matching 1 character in the
string being searched to any of a number of characters
in the search pattern.
• Character classes are defined using square brackets.
So [135] matches any of 1, 3, or 5.
• A range of characters (based on ASCII order) can be
used in a character class: [0-7] matches any digit
between 0 and 7, and [a-z] matches any small (but not
capital) letter. Modifiers (i?) allowed.
14
More Character Classes
• To negate a char class, that is, to match any character
EXCEPT what is in the class, use the caret ^ as the first
symbol in the class. [^0-9] matches any character that
isn’t a digit. [^-0-9] ,matches any char that isn’t a hyphen
or a digit.
• Quantifiers can be used with character classes. [135]+
matches 1 or more of 1, 3, or 5 (in any combination).
[246]{8} matches 8 of 2, 4, and 6 in any combination.
Ex.:HEX: ExecRegExpr('^(0x)?[0-9A-F]+$',ast);
15
Preset Character Classes
• Several groups of characters are so widely used that
they are given special meanings. These don't need to be
put inside square brackets unless you want to include
other chars in the class.
• d = any digit = [0-9]
• s = white-space (spaces, tabs, newlines) = [ tn]
• w - word character = [a-zA-Z0-9_]
• The negation of these classes use the capital letters: D
= any non-digit, S = any non-white-space character, and
W = any non-word chars.
16
Alternatives
• Alternative match patterns are separated
by the “|” character. Thus:
$str = “My pet is a dog.”;
$str =~ /dog|cat|bird/; # matches “dog”
or “cat” or “bird”.
• Note: there is no need to group the chars
with parentheses. Use of a | (pipe) implies
all of the chars between delimiters.
17
Memory Capture
• It is possible to save part or all of the string that matches
the pattern. To do this, simply group chars to be saved in
parentheses. The matching string is saved in scalar vars
starting with $1.
$str = “The z number is z576890”;
$str =~ /is z(d+)/;
print $1; # prints “567890”
• Different variables are counted from left to right by the
position of the opening parenthesis:
/(the ((cat) (runs)))/ ;
captures: $1 = the cat runs; $2 = cat runs; $3 = cat;
$4 = runs. -->ex.
18
Greedy vs. Lazy Matching!?
• The regular expression engine does “greedy” matching by default. This
means that it attempts to match the maximum possible number of
characters, if given a choice. For example:
$str = “The dogggg”;
$str =~ /The (dog+)/;
This prints “dogggg” because “g+”, one or more g’s, is interpreted to mean
the maximum possible number of g’s.
• Greedy matching can cause problems with the use of quantifiers. Imagine
that you have a long DNA sequence and you try to match /ATG(.*)TAG/.
The “.*” matches 0 or more of any character. Greedy matching causes this
to take the entire sequence between the first ATG and the last TAG. This
could be a very long matched sequence.
• Lazy matching matches the minimal number of characters. It is turned on
by putting a question mark “?” after a quantifier. Using the ex. above,
$str =~ /The (dog+?)/; print $1; # prints “dog”
and /ATG(.*?)TAG/ captures everything between the first ATG and the first
TAG that follows. This is usually what you want to do with large sequences.
19
More on Languages
20
Real Examples
• 1. Finding blank lines. They might have a space
or tab on them. so use /^s*$/
• 2. Extracting sub-patterns by index number with
Text Analysis: captureSubString()
• 3. Code Analysis by SONAR Metrics
• 4. Extract Weather Report with JSON
• 5. Get Exchange Rate from HTML
21
More Real REX
• 6. POP Song Finder
Also, there are some common numerical/letter
mixed expressions: 1st for first, for ex. So, w by
itself won’t match everything that we consider a
word in common English.
• 7. Decorate URL' s (big REX called TREX)
Part of hyper-links found must be included into
visible part of URL, for ex.
'http://soft.ch/index.htm' will be decorated as
'<ahref="http://soft.ch/index.htm">soft.ch</a>'.
22
Last Example (Lost)
• const
• URLTemplate =
• '(?i)'
• + '('
• + '(FTP|HTTP)://' // Protocol
• + '|www.)' // trick to catch links without
• // protocol - by detecting of starting 'www.'
• + '([wd-]+(.[wd-]+)+)' // TCP addr or domain name
• + '(:dd?d?d?d?)?' // port number
• + '(((/[%+wd-.]*)+)*)' // unix path
• + '(?[^s=&]+=[^s=&]+(&[^s=&]+=[^s=&]+)*)?'
• // request (GET) params
• + '(#[wd-%+]+)?'; // bookmark
23
Be aware of
• //Greedy or Lazy Pitfall
• Writeln(ReplaceRegExpr('<GTA>(.*?)<TGA>',
'DNA:Test
<GTA>TGAAUUTGA<TGA>GTUUGGGAAACCCA<TGA>-sign','',true));
• //Alarm Range Pitfall {0-255}
• writeln(botoStr(ExecRegExpr('[0-255]+','555'))); //true negative (str false)
• writeln(botoStr(ExecRegExpr('[/D]+','123'))); //false positive (rex false)
{stable design is to consider what it should NOT match}
• //Optional Pitfall - to much options 0..n {empty numbs}
• writeln(botoStr(ExecRegExpr('^d*$','')));
• Regular expressions don’t work very well with nested
delimiters or other tree-like data structures, such as in an
HTML table or an XML document.
24
Conclusion
* a match the character a
* a|b match either a or b
* a? match a or no a (optionality)
* a* match any number of a or no a (optional with repetition)
* a+ match one or more a (required with repetition)
* . match any one character (tab, space or visible char)
* (abc) match characters a, b and c in that order
* [abc] match any one of a, b, c (no order)
* [a-g] match any letter from a to g
* d match any digit [0-9]
* a match any letter [A-Za-z]
* w match any letter or digit [0-9A-Za-z]
* t match a tab (#9)
* n match a newline (#10 or #13)
* b match space (#32) or tab (#9)
* ^ match start of string - * $ matches end of string
25
You choose
• function StripTags2(const S: string): string;
• var
• Len, i, APos: Integer;
• begin
• Len:= Length(S);
• i:= 0;
• Result:= '';
• while (i <= Len) do begin
• Inc(i);
• APos:= ReadUntil(i, len, '<', s);
• Result:= Result + Copy(S, i, APos-i);
• i:= ReadUntil(APos+1,len, '>',s);
• end;
• End;
•
• Writeln(ReplaceRegExpr ('<(.*?)>',
• '<p>This is text.<br/> This is line 2</p>','',true))
http://www.softwareschule.ch/maxbox.htm
26
Thanks a Lot!
https://github.com/maxkleiner/maXbox3/releases

More Related Content

What's hot

Regular Expressions grep and egrep
Regular Expressions grep and egrepRegular Expressions grep and egrep
Regular Expressions grep and egrep
Tri Truong
 
Python - Lecture 7
Python - Lecture 7Python - Lecture 7
Python - Lecture 7
Ravi Kiran Khareedi
 
Python (regular expression)
Python (regular expression)Python (regular expression)
Python (regular expression)
Chirag Shetty
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
Mahzad Zahedi
 
3.2 javascript regex
3.2 javascript regex3.2 javascript regex
3.2 javascript regex
Jalpesh Vasa
 
Bioinformatica 06-10-2011-p2 introduction
Bioinformatica 06-10-2011-p2 introductionBioinformatica 06-10-2011-p2 introduction
Bioinformatica 06-10-2011-p2 introduction
Prof. Wim Van Criekinge
 
Introduction_to_Regular_Expressions_in_R
Introduction_to_Regular_Expressions_in_RIntroduction_to_Regular_Expressions_in_R
Introduction_to_Regular_Expressions_in_R
Hellen Gakuruh
 
Introduction to Regular Expressions
Introduction to Regular ExpressionsIntroduction to Regular Expressions
Introduction to Regular Expressions
Jesse Anderson
 
Introduction to regular expressions
Introduction to regular expressionsIntroduction to regular expressions
Introduction to regular expressions
Ben Brumfield
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
Lambert Lum
 
Regular expression
Regular expressionRegular expression
Regular expression
Larry Nung
 
Regular Expressions and You
Regular Expressions and YouRegular Expressions and You
Regular Expressions and You
James Armes
 
Processing Regex Python
Processing Regex PythonProcessing Regex Python
Processing Regex Python
primeteacher32
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Thomas Langston
 
Regular Expressions 101 Introduction to Regular Expressions
Regular Expressions 101 Introduction to Regular ExpressionsRegular Expressions 101 Introduction to Regular Expressions
Regular Expressions 101 Introduction to Regular Expressions
Danny Bryant
 
Java: Regular Expression
Java: Regular ExpressionJava: Regular Expression
Java: Regular Expression
Masudul Haque
 
15 practical grep command examples in linux
15 practical grep command examples in linux15 practical grep command examples in linux
15 practical grep command examples in linux
Teja Bheemanapally
 
Maxbox starter20
Maxbox starter20Maxbox starter20
Maxbox starter20
Max Kleiner
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
Satya Narayana
 
Regex lecture
Regex lectureRegex lecture
Regex lecture
Jun Shimizu
 

What's hot (20)

Regular Expressions grep and egrep
Regular Expressions grep and egrepRegular Expressions grep and egrep
Regular Expressions grep and egrep
 
Python - Lecture 7
Python - Lecture 7Python - Lecture 7
Python - Lecture 7
 
Python (regular expression)
Python (regular expression)Python (regular expression)
Python (regular expression)
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
3.2 javascript regex
3.2 javascript regex3.2 javascript regex
3.2 javascript regex
 
Bioinformatica 06-10-2011-p2 introduction
Bioinformatica 06-10-2011-p2 introductionBioinformatica 06-10-2011-p2 introduction
Bioinformatica 06-10-2011-p2 introduction
 
Introduction_to_Regular_Expressions_in_R
Introduction_to_Regular_Expressions_in_RIntroduction_to_Regular_Expressions_in_R
Introduction_to_Regular_Expressions_in_R
 
Introduction to Regular Expressions
Introduction to Regular ExpressionsIntroduction to Regular Expressions
Introduction to Regular Expressions
 
Introduction to regular expressions
Introduction to regular expressionsIntroduction to regular expressions
Introduction to regular expressions
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
Regular expression
Regular expressionRegular expression
Regular expression
 
Regular Expressions and You
Regular Expressions and YouRegular Expressions and You
Regular Expressions and You
 
Processing Regex Python
Processing Regex PythonProcessing Regex Python
Processing Regex Python
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Regular Expressions 101 Introduction to Regular Expressions
Regular Expressions 101 Introduction to Regular ExpressionsRegular Expressions 101 Introduction to Regular Expressions
Regular Expressions 101 Introduction to Regular Expressions
 
Java: Regular Expression
Java: Regular ExpressionJava: Regular Expression
Java: Regular Expression
 
15 practical grep command examples in linux
15 practical grep command examples in linux15 practical grep command examples in linux
15 practical grep command examples in linux
 
Maxbox starter20
Maxbox starter20Maxbox starter20
Maxbox starter20
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
Regex lecture
Regex lectureRegex lecture
Regex lecture
 

Similar to Basta mastering regex power

Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekingeBioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
Prof. Wim Van Criekinge
 
Working with text, Regular expressions
Working with text, Regular expressionsWorking with text, Regular expressions
Working with text, Regular expressions
Krasimir Berov (Красимир Беров)
 
Php String And Regular Expressions
Php String  And Regular ExpressionsPhp String  And Regular Expressions
Php String And Regular Expressions
mussawir20
 
Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions
Ahmed El-Arabawy
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
rhshriva
 
Introduction to Regular Expressions RootsTech 2013
Introduction to Regular Expressions RootsTech 2013Introduction to Regular Expressions RootsTech 2013
Introduction to Regular Expressions RootsTech 2013
Ben Brumfield
 
Reg EX
Reg EXReg EX
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Andrea Telatin
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Raj Gupta
 
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdfFUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
Bryan Alejos
 
Regular Expressions 2007
Regular Expressions 2007Regular Expressions 2007
Regular Expressions 2007
Geoffrey Dunn
 
Php Chapter 4 Training
Php Chapter 4 TrainingPhp Chapter 4 Training
Php Chapter 4 Training
Chris Chubb
 
Chapter 3: Introduction to Regular Expression
Chapter 3: Introduction to Regular ExpressionChapter 3: Introduction to Regular Expression
Chapter 3: Introduction to Regular Expression
azzamhadeel89
 
Lecture 10.pdf
Lecture 10.pdfLecture 10.pdf
Lecture 10.pdf
SakhilejasonMsibi
 
Class 5 - PHP Strings
Class 5 - PHP StringsClass 5 - PHP Strings
Class 5 - PHP Strings
Ahmed Swilam
 
Don't Fear the Regex LSP15
Don't Fear the Regex LSP15Don't Fear the Regex LSP15
Don't Fear the Regex LSP15
Sandy Smith
 
Patterns
PatternsPatterns
Patterns
Gayathri91098
 
Intoduction to php strings
Intoduction to php  stringsIntoduction to php  strings
P3 2017 python_regexes
P3 2017 python_regexesP3 2017 python_regexes
P3 2017 python_regexes
Prof. Wim Van Criekinge
 
regex.ppt
regex.pptregex.ppt
regex.ppt
ansariparveen06
 

Similar to Basta mastering regex power (20)

Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekingeBioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
 
Working with text, Regular expressions
Working with text, Regular expressionsWorking with text, Regular expressions
Working with text, Regular expressions
 
Php String And Regular Expressions
Php String  And Regular ExpressionsPhp String  And Regular Expressions
Php String And Regular Expressions
 
Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
 
Introduction to Regular Expressions RootsTech 2013
Introduction to Regular Expressions RootsTech 2013Introduction to Regular Expressions RootsTech 2013
Introduction to Regular Expressions RootsTech 2013
 
Reg EX
Reg EXReg EX
Reg EX
 
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdfFUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
 
Regular Expressions 2007
Regular Expressions 2007Regular Expressions 2007
Regular Expressions 2007
 
Php Chapter 4 Training
Php Chapter 4 TrainingPhp Chapter 4 Training
Php Chapter 4 Training
 
Chapter 3: Introduction to Regular Expression
Chapter 3: Introduction to Regular ExpressionChapter 3: Introduction to Regular Expression
Chapter 3: Introduction to Regular Expression
 
Lecture 10.pdf
Lecture 10.pdfLecture 10.pdf
Lecture 10.pdf
 
Class 5 - PHP Strings
Class 5 - PHP StringsClass 5 - PHP Strings
Class 5 - PHP Strings
 
Don't Fear the Regex LSP15
Don't Fear the Regex LSP15Don't Fear the Regex LSP15
Don't Fear the Regex LSP15
 
Patterns
PatternsPatterns
Patterns
 
Intoduction to php strings
Intoduction to php  stringsIntoduction to php  strings
Intoduction to php strings
 
P3 2017 python_regexes
P3 2017 python_regexesP3 2017 python_regexes
P3 2017 python_regexes
 
regex.ppt
regex.pptregex.ppt
regex.ppt
 

More from Max Kleiner

EKON26_VCL4Python.pdf
EKON26_VCL4Python.pdfEKON26_VCL4Python.pdf
EKON26_VCL4Python.pdf
Max Kleiner
 
EKON26_Open_API_Develop2Cloud.pdf
EKON26_Open_API_Develop2Cloud.pdfEKON26_Open_API_Develop2Cloud.pdf
EKON26_Open_API_Develop2Cloud.pdf
Max Kleiner
 
maXbox_Starter91_SyntheticData_Implement
maXbox_Starter91_SyntheticData_ImplementmaXbox_Starter91_SyntheticData_Implement
maXbox_Starter91_SyntheticData_Implement
Max Kleiner
 
Ekon 25 Python4Delphi_MX475
Ekon 25 Python4Delphi_MX475Ekon 25 Python4Delphi_MX475
Ekon 25 Python4Delphi_MX475
Max Kleiner
 
EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4
Max Kleiner
 
maXbox Starter87
maXbox Starter87maXbox Starter87
maXbox Starter87
Max Kleiner
 
maXbox Starter78 PortablePixmap
maXbox Starter78 PortablePixmapmaXbox Starter78 PortablePixmap
maXbox Starter78 PortablePixmap
Max Kleiner
 
maXbox starter75 object detection
maXbox starter75 object detectionmaXbox starter75 object detection
maXbox starter75 object detection
Max Kleiner
 
BASTA 2020 VS Code Data Visualisation
BASTA 2020 VS Code Data VisualisationBASTA 2020 VS Code Data Visualisation
BASTA 2020 VS Code Data Visualisation
Max Kleiner
 
EKON 24 ML_community_edition
EKON 24 ML_community_editionEKON 24 ML_community_edition
EKON 24 ML_community_edition
Max Kleiner
 
maxbox starter72 multilanguage coding
maxbox starter72 multilanguage codingmaxbox starter72 multilanguage coding
maxbox starter72 multilanguage coding
Max Kleiner
 
EKON 23 Code_review_checklist
EKON 23 Code_review_checklistEKON 23 Code_review_checklist
EKON 23 Code_review_checklist
Max Kleiner
 
EKON 12 Running OpenLDAP
EKON 12 Running OpenLDAP EKON 12 Running OpenLDAP
EKON 12 Running OpenLDAP
Max Kleiner
 
EKON 12 Closures Coding
EKON 12 Closures CodingEKON 12 Closures Coding
EKON 12 Closures Coding
Max Kleiner
 
NoGUI maXbox Starter70
NoGUI maXbox Starter70NoGUI maXbox Starter70
NoGUI maXbox Starter70
Max Kleiner
 
maXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VIImaXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VII
Max Kleiner
 
maXbox starter68 machine learning VI
maXbox starter68 machine learning VImaXbox starter68 machine learning VI
maXbox starter68 machine learning VI
Max Kleiner
 
maXbox starter67 machine learning V
maXbox starter67 machine learning VmaXbox starter67 machine learning V
maXbox starter67 machine learning V
Max Kleiner
 
maXbox starter65 machinelearning3
maXbox starter65 machinelearning3maXbox starter65 machinelearning3
maXbox starter65 machinelearning3
Max Kleiner
 
EKON22_Overview_Machinelearning_Diagrams
EKON22_Overview_Machinelearning_DiagramsEKON22_Overview_Machinelearning_Diagrams
EKON22_Overview_Machinelearning_Diagrams
Max Kleiner
 

More from Max Kleiner (20)

EKON26_VCL4Python.pdf
EKON26_VCL4Python.pdfEKON26_VCL4Python.pdf
EKON26_VCL4Python.pdf
 
EKON26_Open_API_Develop2Cloud.pdf
EKON26_Open_API_Develop2Cloud.pdfEKON26_Open_API_Develop2Cloud.pdf
EKON26_Open_API_Develop2Cloud.pdf
 
maXbox_Starter91_SyntheticData_Implement
maXbox_Starter91_SyntheticData_ImplementmaXbox_Starter91_SyntheticData_Implement
maXbox_Starter91_SyntheticData_Implement
 
Ekon 25 Python4Delphi_MX475
Ekon 25 Python4Delphi_MX475Ekon 25 Python4Delphi_MX475
Ekon 25 Python4Delphi_MX475
 
EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4
 
maXbox Starter87
maXbox Starter87maXbox Starter87
maXbox Starter87
 
maXbox Starter78 PortablePixmap
maXbox Starter78 PortablePixmapmaXbox Starter78 PortablePixmap
maXbox Starter78 PortablePixmap
 
maXbox starter75 object detection
maXbox starter75 object detectionmaXbox starter75 object detection
maXbox starter75 object detection
 
BASTA 2020 VS Code Data Visualisation
BASTA 2020 VS Code Data VisualisationBASTA 2020 VS Code Data Visualisation
BASTA 2020 VS Code Data Visualisation
 
EKON 24 ML_community_edition
EKON 24 ML_community_editionEKON 24 ML_community_edition
EKON 24 ML_community_edition
 
maxbox starter72 multilanguage coding
maxbox starter72 multilanguage codingmaxbox starter72 multilanguage coding
maxbox starter72 multilanguage coding
 
EKON 23 Code_review_checklist
EKON 23 Code_review_checklistEKON 23 Code_review_checklist
EKON 23 Code_review_checklist
 
EKON 12 Running OpenLDAP
EKON 12 Running OpenLDAP EKON 12 Running OpenLDAP
EKON 12 Running OpenLDAP
 
EKON 12 Closures Coding
EKON 12 Closures CodingEKON 12 Closures Coding
EKON 12 Closures Coding
 
NoGUI maXbox Starter70
NoGUI maXbox Starter70NoGUI maXbox Starter70
NoGUI maXbox Starter70
 
maXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VIImaXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VII
 
maXbox starter68 machine learning VI
maXbox starter68 machine learning VImaXbox starter68 machine learning VI
maXbox starter68 machine learning VI
 
maXbox starter67 machine learning V
maXbox starter67 machine learning VmaXbox starter67 machine learning V
maXbox starter67 machine learning V
 
maXbox starter65 machinelearning3
maXbox starter65 machinelearning3maXbox starter65 machinelearning3
maXbox starter65 machinelearning3
 
EKON22_Overview_Machinelearning_Diagrams
EKON22_Overview_Machinelearning_DiagramsEKON22_Overview_Machinelearning_Diagrams
EKON22_Overview_Machinelearning_Diagrams
 

Recently uploaded

Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
Roger Valdez
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
Social Samosa
 
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
74nqk8xf
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
javier ramirez
 
My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.
rwarrenll
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
Lars Albertsson
 
Intelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicineIntelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicine
AndrzejJarynowski
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
Timothy Spann
 
A presentation that explain the Power BI Licensing
A presentation that explain the Power BI LicensingA presentation that explain the Power BI Licensing
A presentation that explain the Power BI Licensing
AlessioFois2
 
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdfUdemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Fernanda Palhano
 
Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...
Bill641377
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
bopyb
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
manishkhaire30
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
Timothy Spann
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
Timothy Spann
 
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
sameer shah
 
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
g4dpvqap0
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Kiwi Creative
 
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
nuttdpt
 
Influence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business PlanInfluence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business Plan
jerlynmaetalle
 

Recently uploaded (20)

Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
 
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
 
My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
 
Intelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicineIntelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicine
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
 
A presentation that explain the Power BI Licensing
A presentation that explain the Power BI LicensingA presentation that explain the Power BI Licensing
A presentation that explain the Power BI Licensing
 
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdfUdemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
 
Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
 
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
 
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
 
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
 
Influence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business PlanInfluence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business Plan
 

Basta mastering regex power

  • 3. 3 The Purpose of REX • Regular expressions are the main way to match patterns within strings or text. For example, finding pieces of text within a larger document, or finding a rule within a code sequence. • There are 3 main methods that use REX: 1. matching (which returns TRUE if a match is found and FALSE if no match is found. 2. search or substitution, which substitutes one pattern of characters for another within a string 3. split, separates a string into a series of sub-strings • REX are composed of chars, character classes, groups, meta-characters, quantifiers, and assertions.
  • 6. 6 But don't end like this
  • 7. 7 Match Operator • If you want to determine whether a string matches a particular pattern, the basic syntax is: Regex regex = new Regex(@"d+"); Match match = regex.Match("Regex 55 Telex"); if (match.Success) { • Two important things here: "d+" is the regex. It means “search the string for the pattern between the "" (d+ here). In the following we use standard Perl notation. • Simple matching returns TRUE or FALSE.
  • 8. 8 Basic Quantifiers • Quantifiers are placed after the character you want to match. • * means 0 or more of the preceding character • + means 1 or more • ? Means 0 or 1 • For example: my $str = “AACCGG”; $str =~ /A+/; # matches AA $str =~ /T+/; # no match $str =~ /T*/; # matches 0 or more T’s $str =~ /Q*/; # matches: 0 or more Q’s • Matching positive or negative 23: $str =~ /-?23/; # i.e. 0 or 1 – sign
  • 9. 9 More Quantifiers • You can specify an exact number of repeats of a character to match using curly braces: $str = “doggggy”; $str =~ /dog{4}y/; # matches 4 g’s $str =~ /dog{3}y/; # no match $str =~ /dog{3}/; # match--no trailing “y” in the pattern. • You can also specify a range by separating a minimum and maximum by a comma within curly braces: $str =~ /dog{1,5}y/; # matches 1,2, 3, 4, or 5 g’s • You can also specify a min. number of chars to match by putting a comma after the minimum number: $str =~ /dog{3,}; # matches 3 or more g’s
  • 10. 10 Grouping with Parentheses • If you want to match a certain number of repeats of a group of characters, you can group the characters within parentheses. For ex., /(cat){3}/ matches 3 reps of “cat” in a row: “catcatcat”. However, /cat{3}/ matches “ca” followed by 3 t’s: “cattt”. • Parentheses also invoke the pattern matching memory, to say capturing.
  • 11. 11 Basic Meta-characters • Some characters mean something other than the literal character. • For example, “+” means “1 or more of the preceding character. What if you want to match a literal plus sign? To do this, escape the + by putting a backslash in front of it: + will match a + sign, but nothing else. • To match a literal backslash, use 2 of them: . • Another important meta-character: “.” matches any character. Thus, /ATG…UGA/ would match ATG followed by 3 additional characters of any type, followed by UGA. • Note that /.*/ matches any string, even the empty string. It means: 0 or more of any character”. • To match a literal period, escape it: . • The “.” doesn’t match a newline. • List of 12 chars that need to be escaped: | / ( ) [ ] { } ^ $ * + ? .
  • 12. 12 Basic Assertions • An assertion is a statement about the position of the match pattern within a string. • The most common assertions are “^”, which signifies the beginning of a string, and “$”, which signifies the end of the string. • Example: my $str = “The dog”; $str =~ /dog/; # matches $str =~ /^dog/; # doesn’t work: “d” must be the first character $str =~ /dog$/; # works: “g” is the last character • Another common assertion: “b” signifies the beginning or end of a word. For example: $str = “There is a dog”; $str =~ /The/ ; # matches $str =~ /Theb/ ; # doesn’t match because the “e” isn’t at the end of the word
  • 13. 13 Character Classes • A character class is a way of matching 1 character in the string being searched to any of a number of characters in the search pattern. • Character classes are defined using square brackets. So [135] matches any of 1, 3, or 5. • A range of characters (based on ASCII order) can be used in a character class: [0-7] matches any digit between 0 and 7, and [a-z] matches any small (but not capital) letter. Modifiers (i?) allowed.
  • 14. 14 More Character Classes • To negate a char class, that is, to match any character EXCEPT what is in the class, use the caret ^ as the first symbol in the class. [^0-9] matches any character that isn’t a digit. [^-0-9] ,matches any char that isn’t a hyphen or a digit. • Quantifiers can be used with character classes. [135]+ matches 1 or more of 1, 3, or 5 (in any combination). [246]{8} matches 8 of 2, 4, and 6 in any combination. Ex.:HEX: ExecRegExpr('^(0x)?[0-9A-F]+$',ast);
  • 15. 15 Preset Character Classes • Several groups of characters are so widely used that they are given special meanings. These don't need to be put inside square brackets unless you want to include other chars in the class. • d = any digit = [0-9] • s = white-space (spaces, tabs, newlines) = [ tn] • w - word character = [a-zA-Z0-9_] • The negation of these classes use the capital letters: D = any non-digit, S = any non-white-space character, and W = any non-word chars.
  • 16. 16 Alternatives • Alternative match patterns are separated by the “|” character. Thus: $str = “My pet is a dog.”; $str =~ /dog|cat|bird/; # matches “dog” or “cat” or “bird”. • Note: there is no need to group the chars with parentheses. Use of a | (pipe) implies all of the chars between delimiters.
  • 17. 17 Memory Capture • It is possible to save part or all of the string that matches the pattern. To do this, simply group chars to be saved in parentheses. The matching string is saved in scalar vars starting with $1. $str = “The z number is z576890”; $str =~ /is z(d+)/; print $1; # prints “567890” • Different variables are counted from left to right by the position of the opening parenthesis: /(the ((cat) (runs)))/ ; captures: $1 = the cat runs; $2 = cat runs; $3 = cat; $4 = runs. -->ex.
  • 18. 18 Greedy vs. Lazy Matching!? • The regular expression engine does “greedy” matching by default. This means that it attempts to match the maximum possible number of characters, if given a choice. For example: $str = “The dogggg”; $str =~ /The (dog+)/; This prints “dogggg” because “g+”, one or more g’s, is interpreted to mean the maximum possible number of g’s. • Greedy matching can cause problems with the use of quantifiers. Imagine that you have a long DNA sequence and you try to match /ATG(.*)TAG/. The “.*” matches 0 or more of any character. Greedy matching causes this to take the entire sequence between the first ATG and the last TAG. This could be a very long matched sequence. • Lazy matching matches the minimal number of characters. It is turned on by putting a question mark “?” after a quantifier. Using the ex. above, $str =~ /The (dog+?)/; print $1; # prints “dog” and /ATG(.*?)TAG/ captures everything between the first ATG and the first TAG that follows. This is usually what you want to do with large sequences.
  • 20. 20 Real Examples • 1. Finding blank lines. They might have a space or tab on them. so use /^s*$/ • 2. Extracting sub-patterns by index number with Text Analysis: captureSubString() • 3. Code Analysis by SONAR Metrics • 4. Extract Weather Report with JSON • 5. Get Exchange Rate from HTML
  • 21. 21 More Real REX • 6. POP Song Finder Also, there are some common numerical/letter mixed expressions: 1st for first, for ex. So, w by itself won’t match everything that we consider a word in common English. • 7. Decorate URL' s (big REX called TREX) Part of hyper-links found must be included into visible part of URL, for ex. 'http://soft.ch/index.htm' will be decorated as '<ahref="http://soft.ch/index.htm">soft.ch</a>'.
  • 22. 22 Last Example (Lost) • const • URLTemplate = • '(?i)' • + '(' • + '(FTP|HTTP)://' // Protocol • + '|www.)' // trick to catch links without • // protocol - by detecting of starting 'www.' • + '([wd-]+(.[wd-]+)+)' // TCP addr or domain name • + '(:dd?d?d?d?)?' // port number • + '(((/[%+wd-.]*)+)*)' // unix path • + '(?[^s=&]+=[^s=&]+(&[^s=&]+=[^s=&]+)*)?' • // request (GET) params • + '(#[wd-%+]+)?'; // bookmark
  • 23. 23 Be aware of • //Greedy or Lazy Pitfall • Writeln(ReplaceRegExpr('<GTA>(.*?)<TGA>', 'DNA:Test <GTA>TGAAUUTGA<TGA>GTUUGGGAAACCCA<TGA>-sign','',true)); • //Alarm Range Pitfall {0-255} • writeln(botoStr(ExecRegExpr('[0-255]+','555'))); //true negative (str false) • writeln(botoStr(ExecRegExpr('[/D]+','123'))); //false positive (rex false) {stable design is to consider what it should NOT match} • //Optional Pitfall - to much options 0..n {empty numbs} • writeln(botoStr(ExecRegExpr('^d*$',''))); • Regular expressions don’t work very well with nested delimiters or other tree-like data structures, such as in an HTML table or an XML document.
  • 24. 24 Conclusion * a match the character a * a|b match either a or b * a? match a or no a (optionality) * a* match any number of a or no a (optional with repetition) * a+ match one or more a (required with repetition) * . match any one character (tab, space or visible char) * (abc) match characters a, b and c in that order * [abc] match any one of a, b, c (no order) * [a-g] match any letter from a to g * d match any digit [0-9] * a match any letter [A-Za-z] * w match any letter or digit [0-9A-Za-z] * t match a tab (#9) * n match a newline (#10 or #13) * b match space (#32) or tab (#9) * ^ match start of string - * $ matches end of string
  • 25. 25 You choose • function StripTags2(const S: string): string; • var • Len, i, APos: Integer; • begin • Len:= Length(S); • i:= 0; • Result:= ''; • while (i <= Len) do begin • Inc(i); • APos:= ReadUntil(i, len, '<', s); • Result:= Result + Copy(S, i, APos-i); • i:= ReadUntil(APos+1,len, '>',s); • end; • End; • • Writeln(ReplaceRegExpr ('<(.*?)>', • '<p>This is text.<br/> This is line 2</p>','',true)) http://www.softwareschule.ch/maxbox.htm