Está en la página 1de 4

INSTITUTO TECNOLOGICO DE TLAXIACO

MATERIA:
LENGUAJES AUTOMATAS
TRABAJO:
EXPRESIONES REGULARES

CATEDRATICO:
ING. JOSE ALFREDO ROMAN CRUZ
ELABARO:
LPEZ PREZ BERTN
REYES ORTIZ RAYMUNDO
RUIZ HERAZ RENE

CARRERA:
ISC
SEMESTRE:
6
GRUPO:
6US

El siguiente trabajo presenta la comprensin, anlisis y aplicacin de las


expresiones regulares utilizando algn software de desarrollo como es java que
servir para codificar algunas expresiones con signo al igual el software JFLAP
para desarrollar algunas cadenas de expresiones regulares.
Expresiones Regulares

Abcde
Ababcdede
Abababcde
Abcdedede
Abcdede
abababcde

Grafos a Expresiones Regulares

Expresin regular:
L= a (b|c)* (de)+ f (ef)+

0101
01
000
010101
01010101
0000
00000

Expresin regular:
L= (ab)+ cd (bcd)+ e (cde)+

Cdigo de la expresin entero con signo:


Es= (+|-|E)D+

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package automata1;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* @author
*/
public class Automata1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String cad;
System.out.print("Introduce cadena: ");
cad = sc.nextLine();
Pattern pat = Pattern.compile("^(?:\\+|-)?\\d+$");
Matcher mat = pat.matcher(cad);
if(mat.find()){
System.out.println("Cadena Vlido");
}else{
System.out.println("Cadena No Vlido");
}
}
}

Cdigo de la expresin letra con signo y digito:


L=(L|_) (L|D|_)*
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package automata1;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* @author RAYMUNDO
*/
public class automata2 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String cad;
System.out.print("Ingrese la cadena: ");
cad = sc.nextLine();
Pattern pat = Pattern.compile("^[a-z|_]+[0-9 a-z|_]*$");
Matcher mat = pat.matcher(cad);
if(mat.find()){
System.out.println("Cadena Vlido");
}else{
System.out.println("Cadena No Vlido");
}
}
}

También podría gustarte