Java代码如下:

import java.util.Scanner;

public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String str = scanner.nextLine(); String[] words = str.replaceAll("[^a-zA-Z ]", "").split("\s+"); for (String word : words) { System.out.println(word); } } }

使用java语言编写代码给定一个由英文字符、数字、空格和英文标点符号组成的字符串长度不超过2000请将其切分为单词要求去掉所有的非英文字母每行输出一个单词。例如有文本:Python was created in 1990 by Guido van Rossum at Stichting Mathematisch Centrum CWI see httpwwwcwinl in the Netherl

原文地址: https://www.cveoy.top/t/topic/bD2l 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录