Jump to content

Pontos finais, Pontos de exclamação e Interrogação


johnamanel

Recommended Posts

Oi pessoal. Sou novo aqui como no Java..... Acreditem..... MMMMTTTT novo

Gostava de saber como retirar os pontos finais, virgulas, pontos de exclamação e um texto etc....

Ou seja:

public class split {

public static void main (String[] args) {
String s = "Para quem é novo no java, isto é muito dificil. A sério!!!";
String[] v;
v = s.split(" ");

for (int i=0; i<v.length; i++)
	System.out.println (v[i]);
}
}

Acho que percebem que, quando uso o split, ele vai por no vector cada "palavra" numa posição. Só que mete também os ","  e os "." e os "!!!".

Por favor ajudem-me.......

Link to comment
Share on other sites

Podes usar expressões regulares e fazes isso em 3 linhas de código.

Deixo-te aqui uns links para te iniciares, aconselho-te a le-los todos:

- http://java.sun.com/docs/books/tutorial/essential/regex/

- http://www.regular-expressions.info/java.html

- https://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html

10 REM Generation 48K!
20 INPUT "URL:", A$
30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50
40 PRINT "404 Not Found"
50 PRINT "./M6 @ Portugal a Programar."

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.