├── README.md ├── bordas ├── BordaPalavra.js ├── Bordas.js ├── Dotall.js └── Multiline.js ├── caracteres ├── AlgunsCuidados.js ├── Brancos.js ├── CaractereSimples.js ├── DesafioListaArquivos.js ├── DesafioTresEspacos.js ├── Metacaracteres.js ├── OlaRegex.js ├── Ou.js ├── Ponto.js ├── ProblemaPonto.js └── Unicode.js ├── conjuntos ├── ConjuntoUnicode.js ├── Conjuntos.js ├── ConjuntosComMetacaracteres.js ├── ConjuntosNegados.js ├── Intervalos.js ├── IntervalosCuidados.js └── Shorthands.js ├── executandoRegex ├── Flags.js ├── UsandoGo.go ├── UsandoJava.class ├── UsandoJava.java ├── UsandoJs.js ├── UsandoPython.py └── UsandoRuby.rb ├── grupos ├── Grupos.js ├── GruposAlgunsCuidados.js ├── GruposAninhados.js ├── GruposEspeciais1.js ├── GruposEspeciais2.rb └── Retrovisor.js ├── quantificadores ├── DesafioCPF.js ├── DesafioEmail.js ├── DesafioTelefone.js ├── Desafios.txt ├── NaoGuloso.js ├── UmMais.js ├── UsandoChaves.js ├── ZeroMais.js └── ZeroUm.js └── receitas ├── ColorirCodigoFonte.js ├── Email.js ├── IntervaloNumerico.js ├── Ipv4.js ├── Senha.js ├── Telefones.js ├── alterados └── codigoFonte.html ├── files.js └── originais └── codigoFonte.html /README.md: -------------------------------------------------------------------------------- 1 | # curso-regex -------------------------------------------------------------------------------- /bordas/BordaPalavra.js: -------------------------------------------------------------------------------- 1 | const texto1 = 'dia diatonico diafragma media wikipedia bom_dia melodia radial' 2 | 3 | console.log(texto1.match(/\bdia\w+/gi)) 4 | console.log(texto1.match(/\w+dia\b/gi)) 5 | console.log(texto1.match(/\w+dia\w+/gi)) 6 | console.log(texto1.match(/\bdia\b/gi)) 7 | 8 | // borda é não \w, que é [^A-Za-z0-9_]... temos problemas com acentos! 9 | const texto2 = 'dia diatônico diafragma, média wikipédia bom-dia melodia radial' 10 | console.log(texto2.match(/\bdia\b/gi)) 11 | console.log(texto2.match(/(\S*)?dia(\S*)?/gi)) // a vírgula entra! 12 | console.log(texto2.match(/([\wÀ-ú-]*)?dia([\wÀ-ú-]*)?/gi)) -------------------------------------------------------------------------------- /bordas/Bordas.js: -------------------------------------------------------------------------------- 1 | const texto = 'Romário era um excelente jogador\n, mas hoje é um político questionador' 2 | 3 | console.log(texto.match(/r/gi)) 4 | console.log(texto.match(/^r/gi)) // ^ inicio da linha/string 5 | console.log(texto.match(/r$/gi)) // $ fim da linha/string 6 | 7 | console.log(texto.match(/^r.*r$/gi)) // problema do dotall -------------------------------------------------------------------------------- /bordas/Dotall.js: -------------------------------------------------------------------------------- 1 | const texto = 'Romário era um excelente jogador\n, mas hoje é um político questionador' 2 | 3 | console.log(texto.match(/^r.*r$/gi)) // problema do dotall 4 | console.log(texto.match(/^r[\s\S]*r$/gi)) -------------------------------------------------------------------------------- /bordas/Multiline.js: -------------------------------------------------------------------------------- 1 | const texto = ` 2 | Leo é muito legal 3 | Emanuel foi jogar em Sergipe 4 | Bianca é casada com Habib 5 | ` 6 | 7 | console.log(texto.match(/\n/g)) 8 | console.log(texto.match(/^(\w).+\1$/gi)) 9 | console.log(texto.match(/^(\w).+\1$/gim)) -------------------------------------------------------------------------------- /caracteres/AlgunsCuidados.js: -------------------------------------------------------------------------------- 1 | const textoUmaLinha = '...' // aspas simples ou duplas 2 | 3 | const textoMultiLinha = ` 4 | linha 1 5 | linha 2 6 | ` 7 | 8 | // cuidado com o tab! 9 | console.log(' '.match(/\s/g)) -------------------------------------------------------------------------------- /caracteres/Brancos.js: -------------------------------------------------------------------------------- 1 | const texto = ` 2 | ca r 3 | r o s! 4 | ` 5 | 6 | console.log(texto.match(/ca\tr\nr\to\ss!/)) -------------------------------------------------------------------------------- /caracteres/CaractereSimples.js: -------------------------------------------------------------------------------- 1 | const texto = '1,2,3,4,5,6,a.b c!d?e' 2 | 3 | const regexVirgula = /,/ 4 | console.log(texto.split(regexVirgula)) 5 | console.log(texto.match(regexVirgula)) 6 | 7 | console.log(texto.match(/,/g)) 8 | console.log(texto.match(/A/g)) 9 | console.log(texto.match(/A/gi)) 10 | console.log(texto.match(/2/g)) 11 | console.log(texto.match(/b c!d/)) -------------------------------------------------------------------------------- /caracteres/DesafioListaArquivos.js: -------------------------------------------------------------------------------- 1 | const texto = 'lista de arquivos mp3: jazz.mp3,rock.mp3,podcast.mp3,blues.mp3' 2 | console.log(texto.match(/\.mp3/g)) 3 | 4 | // no futuro... 5 | console.log(texto.match(/\w+\.mp3/g)) -------------------------------------------------------------------------------- /caracteres/DesafioTresEspacos.js: -------------------------------------------------------------------------------- 1 | const texto = 'a b' 2 | console.log(texto.match(/a b/)) 3 | console.log(texto.match(/a\s\s\sb/)) 4 | 5 | // no futuro... 6 | console.log(texto.match(/a\s+b/)) 7 | console.log(texto.match(/a {3}b/)) 8 | console.log(texto.match(/a\s{3}b/)) -------------------------------------------------------------------------------- /caracteres/Metacaracteres.js: -------------------------------------------------------------------------------- 1 | // . ? * + - ^ $ | [ ] { } ( ) \ : 2 | const texto = '1,2,3,4,5,6,a.b c!d?e' 3 | const regexPonto = /\./g 4 | console.log(texto.split(regexPonto)) 5 | 6 | const regexSimbolos = /,|\.|\?|!| /g 7 | console.log(texto.split(regexSimbolos)) -------------------------------------------------------------------------------- /caracteres/OlaRegex.js: -------------------------------------------------------------------------------- 1 | const texto = 'Casa bonita é casa amarela da esquina com a Rua ACASALAR.' 2 | 3 | const regex = /casa/gi 4 | console.log(texto.match(regex)) 5 | console.log(texto.match(/a b/)) -------------------------------------------------------------------------------- /caracteres/Ou.js: -------------------------------------------------------------------------------- 1 | const texto = 'Você precisa responder sim, não ou não sei!' 2 | console.log(texto.match(/sim|não|sei/g)) // alternativa (OU) -------------------------------------------------------------------------------- /caracteres/Ponto.js: -------------------------------------------------------------------------------- 1 | // . é um coringa, válido para uma posição 2 | 3 | const texto = '1,2,3,4,5,6,7,8,9,0' 4 | 5 | console.log(texto.match(/1.2/g)) 6 | console.log(texto.match(/1..2/g)) 7 | console.log(texto.match(/1..,/g)) 8 | 9 | const notas = '8.3,7.1,8.8,10.0' 10 | console.log(notas.match(/8../g)) 11 | console.log(notas.match(/.\../g)) -------------------------------------------------------------------------------- /caracteres/ProblemaPonto.js: -------------------------------------------------------------------------------- 1 | const texto = 'Bom\ndia' 2 | console.log(texto.match(/.../gi)) 3 | console.log(texto.match(/..../gi)) // o ponto não engloba o \n 4 | 5 | // dotall - algums linguagens tem um flag /exp/s, mas JS não! -------------------------------------------------------------------------------- /caracteres/Unicode.js: -------------------------------------------------------------------------------- 1 | // no início... 2 | // Um byte (8 bits) - 256 caracteres 3 | // Símbolos, Pontuação, A-Z, a-z, 0-9 4 | 5 | // Dois bytes (16 bits) - 65500+ caracteres 6 | // +Símbolos, +Pontuação, A-Z, a-z, 0-9 7 | 8 | // Unicode 9 | // Quantidade de Bytes Variável - Expansível 10 | // Suporta mais de 1 Milhão caracteres 11 | // Atualmente tem mais de 100.000 caracteres atribuidos 12 | 13 | // https://unicode-table.com/pt/ 14 | 15 | const texto = 'aʬc௵d' 16 | console.log(texto.match(/\u02AC|\u0BF5/g)) -------------------------------------------------------------------------------- /conjuntos/ConjuntoUnicode.js: -------------------------------------------------------------------------------- 1 | const texto = 'áéíóú àèìòù âêîôû ç ãõ ü' 2 | console.log(texto.match(/[À-ü]/g)) -------------------------------------------------------------------------------- /conjuntos/Conjuntos.js: -------------------------------------------------------------------------------- 1 | const texto = '1,2,3,4,5,6,a.b c!d?e[f' 2 | 3 | // para definir uma classe (ou conjunto) de caracteres usa [] 4 | const regexPares = /[02468]/g 5 | console.log(texto.match(regexPares)) 6 | 7 | const texto2 = 'João não vai passear na moto.' 8 | const regexComESemAcento = /n[aã]/g 9 | console.log(texto2.match(regexComESemAcento)) -------------------------------------------------------------------------------- /conjuntos/ConjuntosComMetacaracteres.js: -------------------------------------------------------------------------------- 1 | const texto = '.$+*?-' 2 | 3 | console.log(texto.match(/[+.?*$]./g)) // não precisa de escape dentro do conjunto 4 | console.log(texto.match(/[$-?]/g)) // isso é um intervalo (range) 5 | 6 | // NÃO é um intervalo (range)... 7 | console.log(texto.match(/[$\-?]/g)) 8 | console.log(texto.match(/[-?]/g)) 9 | 10 | // pode precisar de escape dentro do conjunto: - [ ] ^ -------------------------------------------------------------------------------- /conjuntos/ConjuntosNegados.js: -------------------------------------------------------------------------------- 1 | const texto = '1,2,3,a.b c!d?e[f' 2 | 3 | console.log(texto.match(/\D/g)) 4 | console.log(texto.match(/[^0-9]/g)) 5 | console.log(texto.match(/[^\d!\?\[\s,\.]/g)) 6 | 7 | const texto2 = '1: !"#$%&\'()*+,-./ 2: :;<=>?@' 8 | 9 | console.log(texto2.match(/[^!-/:-@\s]/g)) -------------------------------------------------------------------------------- /conjuntos/Intervalos.js: -------------------------------------------------------------------------------- 1 | const texto = '1,2,3,4,5,6,a.b c!d?e[f' 2 | 3 | console.log(texto.match(/[a-z]/g)) 4 | console.log(texto.match(/[b-d]/g)) 5 | console.log(texto.match(/[2-4]/g)) 6 | console.log(texto.match(/[A-Z1-3]/gi)) -------------------------------------------------------------------------------- /conjuntos/IntervalosCuidados.js: -------------------------------------------------------------------------------- 1 | const texto = 'ABC [abc] a-c 1234' 2 | 3 | console.log(texto.match(/[a-c]/g)) 4 | console.log(texto.match(/a-c/g)) // não define um range 5 | 6 | console.log(texto.match(/[A-z]/g)) // intervalos usam a ordem da tabela UNICODE 7 | 8 | // tem que respeitar a ordem da tabela UNICODE 9 | // console.log(texto.match(/[a-Z]/g)) 10 | // console.log(texto.match(/[4-1]/g)) -------------------------------------------------------------------------------- /conjuntos/Shorthands.js: -------------------------------------------------------------------------------- 1 | const texto = `1,2,3,4,5,6,a.b c!d?e\r - 2 | f_g` 3 | 4 | console.log(texto.match(/\d/g)) // números [0-9] 5 | console.log(texto.match(/\D/g)) // não números [^0-9] 6 | 7 | console.log(texto.match(/\w/g)) // caracteres [a-zA-Z0-9_] 8 | console.log(texto.match(/\W/g)) // não caracteres [^a-zA-Z0-9_] 9 | 10 | console.log(texto.match(/\s/g)) // espaço [ \t\n\r\f] 11 | console.log(texto.match(/\S/g)) // não espaço [^ \t\n\r\f] 12 | 13 | // \b \B -------------------------------------------------------------------------------- /executandoRegex/Flags.js: -------------------------------------------------------------------------------- 1 | // g - global 2 | // i - ignore case 3 | 4 | const texto = 'Carlos assinou o abaixo-assinado.' 5 | console.log(texto.match(/C|ab/)) 6 | console.log(texto.match(/c|ab/i)) 7 | console.log(texto.match(/ab|c/gi)) -------------------------------------------------------------------------------- /executandoRegex/UsandoGo.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "regexp" 7 | ) 8 | 9 | func main() { 10 | texto := "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f" 11 | 12 | regex9, _ := regexp.Compile("9") 13 | fmt.Println(regex9.MatchString(texto)) 14 | fmt.Println(regex9.FindString(texto)) 15 | fmt.Println(regex9.FindStringIndex(texto)) 16 | 17 | regexLetras, _ := regexp.Compile("[a-f]") 18 | fmt.Println(regexLetras.FindAllString(texto, 20)) 19 | fmt.Println(regexLetras.ReplaceAllString(texto, "Achei")) 20 | 21 | resultado := regexLetras.ReplaceAllFunc([]byte(texto), bytes.ToUpper) 22 | fmt.Println(string(resultado)) 23 | } 24 | -------------------------------------------------------------------------------- /executandoRegex/UsandoJava.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cod3rcursos/curso-regex/b3b83fd9b21b64a31470038e4e64fcf8c2cd0437/executandoRegex/UsandoJava.class -------------------------------------------------------------------------------- /executandoRegex/UsandoJava.java: -------------------------------------------------------------------------------- 1 | import java.util.regex.*; 2 | 3 | public class UsandoJava { 4 | public static void main(String[] args) { 5 | String texto = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f"; 6 | Pattern patternLetras = Pattern.compile("[a-f]"); 7 | Matcher matcher = patternLetras.matcher(texto); 8 | 9 | while (matcher.find()) { 10 | System.out.printf("Posicoes: %s, %s\tValor: %s%n", 11 | matcher.start(), matcher.end(), matcher.group()); 12 | } 13 | 14 | System.out.println(texto.replaceAll("[7-9]", "Achei")); 15 | } 16 | } -------------------------------------------------------------------------------- /executandoRegex/UsandoJs.js: -------------------------------------------------------------------------------- 1 | const texto = '0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f' 2 | 3 | const regexNove = RegExp('9') 4 | console.log('Métodos da RegExp...') 5 | console.log(regexNove.test(texto)) 6 | console.log(regexNove.exec(texto)) 7 | 8 | const regexLetras = /[a-f]/g 9 | console.log('Métodos da string...') 10 | console.log(texto.match(regexLetras)) 11 | console.log(texto.search(regexLetras)) 12 | console.log(texto.replace(regexLetras, 'Achei')) 13 | console.log(texto.split(regexLetras)) -------------------------------------------------------------------------------- /executandoRegex/UsandoPython.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | texto = '0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f' 4 | 5 | pattern9 = re.compile('9') 6 | match1 = re.search(pattern9, texto) 7 | print "Posicoes: %s, %s; Valor: %s." % (match1.start(), match1.end(), match1.group(0)) 8 | 9 | valores = re.findall('[a-f]', texto) 10 | print "Valores: %s" % valores -------------------------------------------------------------------------------- /executandoRegex/UsandoRuby.rb: -------------------------------------------------------------------------------- 1 | texto = '0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f' 2 | regexNove = Regexp::new('9') 3 | puts regexNove.match(texto) 4 | 5 | regexNove = %r{9} 6 | puts regexNove.match(texto) 7 | 8 | p regexNove =~ '894' 9 | 10 | regexLetras = /[a-f]/ 11 | puts texto.scan(regexLetras).join(' ') 12 | 13 | puts texto.split(/,/).join 14 | 15 | print texto.split(/[aeiou]/) -------------------------------------------------------------------------------- /grupos/Grupos.js: -------------------------------------------------------------------------------- 1 | const texto1 = 'O José Simão é muito engraçado... hehehehehehe' 2 | console.log(texto1.match(/(he)+/g)) 3 | 4 | const texto2 = 'http://www.site.info www.escola.ninja.br google.com.ag' 5 | console.log(texto2.match(/(http:\/\/)?(www\.)?\w+\.\w{2,}(\.\w{2})?/g)) -------------------------------------------------------------------------------- /grupos/GruposAlgunsCuidados.js: -------------------------------------------------------------------------------- 1 | const texto = 'Pedrinho (filho do Pedro Silva) é doutor do ABCabc!' 2 | 3 | console.log(texto.match(/[(abc)]/gi)) // não é um grupo 4 | console.log(texto.match(/([abc])/gi)) 5 | console.log(texto.match(/(abc)+/gi)) -------------------------------------------------------------------------------- /grupos/GruposAninhados.js: -------------------------------------------------------------------------------- 1 | const texto = 'supermercado hipermercado minimercado mercado' 2 | 3 | console.log(texto.match(/(super|hiper|mini)?mercado/g)) 4 | console.log(texto.match(/((hi|su)per|mini)?mercado/g)) -------------------------------------------------------------------------------- /grupos/GruposEspeciais1.js: -------------------------------------------------------------------------------- 1 | const texto = 'João é calmo, mas no transito fica nervoso.' 2 | 3 | console.log(texto.match(/[\wÀ-ú]+/gi)) 4 | 5 | // Positive lookahead 6 | console.log(texto.match(/[\wÀ-ú]+(?=,)/gi)) 7 | console.log(texto.match(/[\wÀ-ú]+(?=\.)/gi)) 8 | console.log(texto.match(/[\wÀ-ú]+(?=, mas)/gi)) 9 | 10 | // Negative lookahead 11 | console.log(texto.match(/[\wÀ-ú]+\b(?!,)/gi)) 12 | console.log(texto.match(/[\wÀ-ú]+[\s|\.](?!,)/gi)) -------------------------------------------------------------------------------- /grupos/GruposEspeciais2.rb: -------------------------------------------------------------------------------- 1 | texto = 'supermercado superação hiperMERCADO Mercado' 2 | 3 | puts texto.scan(/(?:super)[\wÀ-ú]+/i).join(' ') 4 | 5 | # Positive Lookbehind 6 | puts texto.scan(/(?<=super)[\wÀ-ú]+/i).join(' ') 7 | 8 | # Negative Lookbehind 9 | puts texto.scan(/(?DestaqueForte
[\s\S]*<\/code>/i
7 | let codigo = texto.match(codeRegex)[0]
8 |
9 | // String...
10 | codigo = aplicarCor(codigo, /(\".*\")/g, 'ce9178')
11 |
12 | // palavras reservadas
13 | codigo = aplicarCor(codigo, /\b(package|public|class|static|if|else)\b/g, 'd857cf')
14 |
15 | // tipos...
16 | codigo = aplicarCor(codigo, /\b(void|int)\b/g, '1385e2')
17 |
18 | // comentários de multiplas linhas...
19 | codigo = aplicarCor(codigo, /(\/\*[\s\S]*\*\/)/g, '267703')
20 |
21 | // comentários de uma linha...
22 | codigo = aplicarCor(codigo, /(\/\/.*?\n)/g, '267703')
23 |
24 | const conteudoFinal = texto.replace(codeRegex, codigo)
25 | files.write('codigoFonte.html', conteudoFinal)
--------------------------------------------------------------------------------
/receitas/Email.js:
--------------------------------------------------------------------------------
1 | const texto = `
2 | Os e-mails dos convidados são:
3 | - fulano@cod3r.com.br
4 | - xico@gmail.com
5 | - joao@empresa.info.br
6 | - maria_silva@registro.br
7 | - rafa.sampaio@yahoo.com
8 | - fulano+de+tal@escola.ninja.br
9 | `
10 |
11 | console.log(texto.match(/\S+@\w+\.\w{2,6}(\.\w{2})?/g))
--------------------------------------------------------------------------------
/receitas/IntervaloNumerico.js:
--------------------------------------------------------------------------------
1 | const texto = '0 1 10 192 199 201 249 255 256 312 1010 1512'
2 |
3 | // números entre 0-255
4 | console.log(texto.match(/\b(\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])\b/g))
--------------------------------------------------------------------------------
/receitas/Ipv4.js:
--------------------------------------------------------------------------------
1 | const texto = `
2 | Inválidos:
3 | 192.268.0.1
4 | 1.333.1.1
5 | 192.168.0.256
6 | 256.256.256.256
7 |
8 | Válidos:
9 | 192.168.0.1
10 | 127.0.0.1
11 | 10.0.0.255
12 | 10.11.12.0
13 | 255.255.255.255
14 | 0.0.0.0
15 | `
16 |
17 | const n = '(\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])'
18 | const ipv4 = RegExp(`\\b${n}\\.${n}\\.${n}\\.${n}\\b`, 'g')
19 | console.log(texto.match(ipv4))
--------------------------------------------------------------------------------
/receitas/Senha.js:
--------------------------------------------------------------------------------
1 | const texto = `
2 | 123456
3 | cod3r
4 | QUASE123!
5 | #OpA1
6 | #essaSenhaEGrande1234
7 |
8 | #OpA1?
9 | Foi123!
10 | `
11 |
12 | console.log(texto.match(/^.{6,20}$/gm))
13 | console.log(texto.match(/^(?=.*[A-Z]).{6,20}$/gm))
14 | console.log(texto.match(/^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[@#$%!^&*]).{6,20}$/gm))
--------------------------------------------------------------------------------
/receitas/Telefones.js:
--------------------------------------------------------------------------------
1 | const texto = `
2 | Lista telefônica:
3 | - (21) 12345-6789
4 | - (11) 62300-2234
5 | - 5678-7771
6 | - (85)3333-7890
7 | - (1) 4321-1234
8 | `
9 |
10 | console.log(texto.match(/(\(\d{2}\)\s?)?\d{4,5}-\d{4}/g))
--------------------------------------------------------------------------------
/receitas/alterados/codigoFonte.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Código Fonte
8 |
11 |
12 |
13 | Código Fonte
14 |
15 |
16 | package cod3r;
17 |
18 | /*
19 | * Imprimir a nota do aluno
20 | */
21 | public class Nota {
22 |
23 | // Porta de entrada de um programa Java
24 | public static void main(String[] args) {
25 | int nota = 7;
26 |
27 | if(nota >= 7) {
28 | System.out.println("Aprovado");
29 | } else {
30 | System.out.println("Reprovado");
31 | }
32 | }
33 | }
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/receitas/files.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs')
2 |
3 | const read = nomeArquivo =>
4 | fs.readFileSync(`${__dirname}/originais/${nomeArquivo}`, { encoding: 'utf8' })
5 |
6 |
7 | const write = (nomeArquivo, conteudo) => {
8 | const dirname = `${__dirname}/alterados`
9 | if (!fs.existsSync(dirname)) {
10 | fs.mkdirSync(dirname)
11 | }
12 |
13 | fs.writeFileSync(`${dirname}/${nomeArquivo}`, conteudo, { encoding: 'utf8' })
14 | }
15 |
16 | module.exports = { read, write }
--------------------------------------------------------------------------------
/receitas/originais/codigoFonte.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Código Fonte
8 |
11 |
12 |
13 | Código Fonte
14 |
15 |
16 | package cod3r;
17 |
18 | /*
19 | * Imprimir a nota do aluno
20 | */
21 | public class Nota {
22 |
23 | // Porta de entrada de um programa Java
24 | public static void main(String[] args) {
25 | int nota = 7;
26 |
27 | if(nota >= 7) {
28 | System.out.println("Aprovado");
29 | } else {
30 | System.out.println("Reprovado");
31 | }
32 | }
33 | }
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------