diff --git a/README-pt_BR.md b/README-pt_BR.md index ecb5f3f..bdb477f 100644 --- a/README-pt_BR.md +++ b/README-pt_BR.md @@ -25,37 +25,37 @@ Imagine que você está escrevendo uma aplicação e quer colocar regras para qu A expressão regular acima aceita as strings `john_doe`, `jo-hn_doe` e `john12_as`. Ela não aceita `Jo` porque essa string contém letras maiúsculas e também é muito curta. -## Table of Contents +## Sumário -- [Basic Matchers](#1-basic-matchers) -- [Meta character](#2-meta-characters) - - [Full stop](#21-full-stop) - - [Character set](#22-character-set) - - [Negated character set](#221-negated-character-set) - - [Repetitions](#23-repetitions) - - [The Star](#231-the-star) - - [The Plus](#232-the-plus) - - [The Question Mark](#233-the-question-mark) - - [Braces](#24-braces) - - [Character Group](#25-character-group) - - [Alternation](#26-alternation) - - [Escaping special character](#27-escaping-special-character) - - [Anchors](#28-anchors) - - [Caret](#281-caret) - - [Dollar](#282-dollar) -- [Shorthand Character Sets](#3-shorthand-character-sets) -- [Lookaround](#4-lookaround) - - [Positive Lookahead](#41-positive-lookahead) - - [Negative Lookahead](#42-negative-lookahead) - - [Positive Lookbehind](#43-positive-lookbehind) - - [Negative Lookbehind](#44-negative-lookbehind) +- [Combinações Básicas](#1-basic-matchers) +- [Metacaracteres](#2-meta-characters) + - [Ponto final](#21-full-stop) + - [Conjunto de caracteres](#22-character-set) + - [Conjunto de caracteres negados](#221-negated-character-set) + - [Repetições](#23-repetitions) + - [O Asterisco](#231-the-star) + - [O Sinal de Adição](#232-the-plus) + - [O Ponto de Interrogação](#233-the-question-mark) + - [Chaves](#24-braces) + - [Grupo de Caracteres](#25-character-group) + - [Alternância](#26-alternation) + - [Escapando Caracteres Especiais](#27-escaping-special-character) + - [Âncoras](#28-anchors) + - [Acento Circunflexo](#281-caret) + - [Sinal de Dólar](#282-dollar) +- [Forma Abreviada de Conjunto de Caracteres](#3-shorthand-character-sets) +- [Olhar ao Redor](#4-lookaround) + - [Lookahead Positivo](#41-positive-lookahead) + - [Lookahead Negativo](#42-negative-lookahead) + - [Lookbehind Positivo](#43-positive-lookbehind) + - [Lookbehind Negativo](#44-negative-lookbehind) - [Flags](#5-flags) - - [Case Insensitive](#51-case-insensitive) - - [Global search](#52-global-search) - - [Multiline](#53-multiline) -- [Bonus](#bonus) + - [Indiferente à Maiúsculas](#51-case-insensitive) + - [Busca Global](#52-global-search) + - [Multilinhas](#53-multiline) +- [Bônus](#bonus) -## 1. Basic Matchers +## 1. Combinações Básicas A regular expression is just a pattern of characters that we use to perform search in a text. For example, the regular expression `the` means: the letter `t`, followed by the letter `h`, followed by the letter `e`. @@ -76,7 +76,7 @@ case-sensitive so the regular expression `The` would not match the string `the`. [Test the regular expression](https://regex101.com/r/1paXsy/1) -## 2. Meta Characters +## 2. Metacaracteres Meta characters are the building blocks of the regular expressions. Meta characters do not stand for themselves but instead are interpreted in some special way. Some meta characters have a special meaning and are written inside square brackets. @@ -90,16 +90,16 @@ The meta characters are as follows: |*|Matches 0 or more repetitions of the preceding symbol.| |+|Matches 1 or more repetitions of the preceding symbol. |?|Makes the preceding symbol optional.| -|{n,m}|Braces. Matches at least "n" but not more than "m" repetitions of the preceding symbol.| +|{n,m}|Chaves. Matches at least "n" but not more than "m" repetitions of the preceding symbol.| |(xyz)|Character group. Matches the characters xyz in that exact order.| -|||Alternation. Matches either the characters before or the characters after the symbol.| +|||Alternância. Matches either the characters before or the characters after the symbol.| |\|Escapes the next character. This allows you to match reserved characters [ ] ( ) { } . * + ? ^ $ \ || |^|Matches the beginning of the input.| |$|Matches the end of the input.| -## 2.1 Full stop +## 2.1 Ponto final -Full stop `.` is the simplest example of meta character. The meta character `.` matches any single character. It will not match return +Ponto final `.` is the simplest example of meta character. The meta character `.` matches any single character. It will not match return or newline characters. For example, the regular expression `.ar` means: any character, followed by the letter `a`, followed by the letter `r`. @@ -109,7 +109,7 @@ letter `r`. [Test the regular expression](https://regex101.com/r/xc9GkU/1) -## 2.2 Character set +## 2.2 Conjunto de caracteres Character sets are also called character class. Square brackets are used to specify character sets. Use a hyphen inside a character set to specify the characters' range. The order of the character range inside square brackets doesn't matter. For example, the regular @@ -129,7 +129,7 @@ A period inside a character set, however, means a literal period. The regular ex [Test the regular expression](https://regex101.com/r/wL3xtE/1) -### 2.2.1 Negated character set +### 2.2.1 Conjunto de caracteres negados In general, the caret symbol represents the start of the string, but when it is typed after the opening square bracket it negates the character set. For example, the regular expression `[^c]ar` means: any character except `c`, followed by the character `a`, followed by @@ -141,12 +141,12 @@ the letter `r`. [Test the regular expression](https://regex101.com/r/nNNlq3/1) -## 2.3 Repetitions +## 2.3 Repetições Following meta characters `+`, `*` or `?` are used to specify how many times a subpattern can occur. These meta characters act differently in different situations. -### 2.3.1 The Star +### 2.3.1 O Asterisco The symbol `*` matches zero or more repetitions of the preceding matcher. The regular expression `a*` means: zero or more repetitions of preceding lowercase character `a`. But if it appears after a character set or class then it finds the repetitions of the whole @@ -169,7 +169,7 @@ zero or more spaces. [Test the regular expression](https://regex101.com/r/gGrwuz/1) -### 2.3.2 The Plus +### 2.3.2 O Sinal de Adição The symbol `+` matches one or more repetitions of the preceding character. For example, the regular expression `c.+t` means: lowercase letter `c`, followed by at least one character, followed by the lowercase character `t`. @@ -180,7 +180,7 @@ letter `c`, followed by at least one character, followed by the lowercase charac [Test the regular expression](https://regex101.com/r/Dzf9Aa/1) -### 2.3.3 The Question Mark +### 2.3.3 O Ponto de Interrogação In regular expression the meta character `?` makes the preceding character optional. This symbol matches zero or one instance of the preceding character. For example, the regular expression `[T]?he` means: Optional the uppercase letter `T`, followed by the lowercase @@ -198,7 +198,7 @@ character `h`, followed by the lowercase character `e`. [Test the regular expression](https://regex101.com/r/kPpO2x/1) -## 2.4 Braces +## 2.4 Chaves In regular expression braces that are also called quantifiers are used to specify the number of times that a character or a group of characters can be repeated. For example, the regular expression `[0-9]{2,3}` means: Match at least 2 digits but not more than 3 ( @@ -225,7 +225,7 @@ the comma the regular expression `[0-9]{3}` means: Match exactly 3 digits. [Test the regular expression](https://regex101.com/r/Sivu30/1) -## 2.5 Character Group +## 2.5 Grupo de Caracteres Character group is a group of sub-patterns that is written inside Parentheses `(...)`. As we discussed before that in regular expression if we put a quantifier after a character then it will repeat the preceding character. But if we put quantifier after a character group then @@ -239,7 +239,7 @@ We can also use the alternation `|` meta character inside character group. For e [Test the regular expression](https://regex101.com/r/tUxrBG/1) -## 2.6 Alternation +## 2.6 Alternância In regular expression Vertical bar `|` is used to define alternation. Alternation is like a condition between multiple expressions. Now, you may be thinking that character set and alternation works the same way. But the big difference between character set and alternation @@ -253,7 +253,7 @@ or lowercase character `c`, followed by lowercase character `a`, followed by low [Test the regular expression](https://regex101.com/r/fBXyX0/1) -## 2.7 Escaping special character +## 2.7 Escapando Caracteres Especiais Backslash `\` is used in regular expression to escape the next character. This allows to to specify a symbol as a matching character including reserved characters `{ } [ ] / \ + * . $ ^ | ?`. To use a special character as a matching character prepend `\` before it. @@ -267,16 +267,16 @@ expression `(f|c|m)at\.?` means: lowercase letter `f`, `c` or `m`, followed by l [Test the regular expression](https://regex101.com/r/DOc5Nu/1) -## 2.8 Anchors +## 2.8 Âncoras In regular expressions, we use anchors to check if the matching symbol is the starting symbol or ending symbol of the -input string. Anchors are of two types: First type is Caret `^` that check if the matching character is the start -character of the input and the second type is Dollar `$` that checks if matching character is the last character of the +input string. Âncoras are of two types: First type is Acento Circunflexo `^` that check if the matching character is the start +character of the input and the second type is Sinal de Dólar `$` that checks if matching character is the last character of the input string. -### 2.8.1 Caret +### 2.8.1 Acento Circunflexo -Caret `^` symbol is used to check if matching character is the first character of the input string. If we apply the following regular +Acento Circunflexo `^` symbol is used to check if matching character is the first character of the input string. If we apply the following regular expression `^a` (if a is the starting symbol) to input string `abc` it matches `a`. But if we apply regular expression `^b` on above input string it does not match anything. Because in input string `abc` "b" is not the starting symbol. Let's take a look at another regular expression `^(T|t)he` which means: uppercase character `T` or lowercase character `t` is the start symbol of the input string, @@ -294,9 +294,9 @@ followed by lowercase character `h`, followed by lowercase character `e`. [Test the regular expression](https://regex101.com/r/jXrKne/1) -### 2.8.2 Dollar +### 2.8.2 Sinal de Dólar -Dollar `$` symbol is used to check if matching character is the last character of the input string. For example, regular expression +Sinal de Dólar `$` symbol is used to check if matching character is the last character of the input string. For example, regular expression `(at\.)$` means: a lowercase character `a`, followed by lowercase character `t`, followed by a `.` character and the matcher must be end of the string. @@ -312,7 +312,7 @@ must be end of the string. [Test the regular expression](https://regex101.com/r/t0AkOd/1) -## 3. Shorthand Character Sets +## 3. Forma Abreviada de Conjunto de Caracteres Regular expression provides shorthands for the commonly used character sets, which offer convenient shorthands for commonly used regular expressions. The shorthand character sets are as follows: @@ -327,7 +327,7 @@ regular expressions. The shorthand character sets are as follows: |\s|Matches whitespace character: `[\t\n\f\r\p{Z}]`| |\S|Matches non-whitespace character: `[^\s]`| -## 4. Lookaround +## 4. Olhar ao Redor Lookbehind and lookahead sometimes known as lookaround are specific type of ***non-capturing group*** (Use to match the pattern but not included in matching list). Lookaheads are used when we have the condition that this pattern is preceded or followed by another certain @@ -337,12 +337,12 @@ by `$` character. Following are the lookarounds that are used in regular express |Symbol|Description| |:----:|----| -|?=|Positive Lookahead| -|?!|Negative Lookahead| -|?<=|Positive Lookbehind| -|?