是否有必要使用句子通知单句?即使它被认为是正确的语法,它看起来很丑陋,感觉太正式了.
这里有两个用于比较的屏幕(第一个包括期间,第二个没有).
我有一个大型数据框,其中包含一列字符串数据,当前包含一组名称,在某些情况下还包含一个电子邮件地址.我想找一个正则表达式,允许我在第二个逗号之前设置位置,在这些情况下使用电子邮件地址,然后删除后面的内容,以便我留下一个名字的"作者"列,不包括电子邮件.
> author<-c("Doe, Jane", "Smith, John", "Doe, John, johndoe@xyz.net", "Smith, Jane")
> ID<- c(1:4)
> df<-cbind(author, ID)
> df
author ID
[1,] Doe, Jane 1
[2,] Smith, John 2
[3,] Doe, John, johndoe@xyz.net 3
[4,] Smith, Jane 4
Run Code Online (Sandbox Code Playgroud)
我希望输出看起来如下
>df
author ID
[1,] Doe, Jane 1
[2,] Smith, John 2
[3,] Doe, John 3
[4,] Smith, Jane 4
Run Code Online (Sandbox Code Playgroud) 我需要删除文件上的标点符号读取,保持重音字符我尝试了这段代码,但不按我的意思工作.
Expectation: input=> ’'qwe..,rty ‘èeéò’“ ”o" "à output=> qwertyèeéòoà
Effective result: input=> ’'qwe..,rty ‘èeéò’“ ”o" "à output=>’qwerty ‘èeéò’“ ”o" "à
Run Code Online (Sandbox Code Playgroud)
我无法删除 ’“” 符号和其他这些
注意:Eclipse并filetext.txt设置为UTF-8.
谢谢
import java.io.*;
import java.util.Scanner;
public class DataCounterMain {
public static void main (String[] args) throws FileNotFoundException {
File file = new File("filetext.txt");
try {
Scanner filescanner = new Scanner(file);
while (filescanner.hasNextLine()) {
String line = filescanner.nextLine();
line=line.replaceAll ("\\p{Punct}", "");
System.out.println(line);
}
}
catch(FileNotFoundException e) {
System.err.println(file +" FileNotFound");
} …Run Code Online (Sandbox Code Playgroud) 我想在条款末尾和句子开始使用问号.为了表明这一点,我想在下面使用带逗号的问号,我想称之为quomma.
对于这种非传统的标点符号,似乎没有Unicode代码点,那么最友好的网络方式是什么?
我正在使用emacs和auctex来编写LaTeX文档.出于某种原因,我没有像我在完成教程时那样在tex模式中移动到句子的末尾.它移到段落的末尾.(也就是说,它会在下一个双线休息之前移动)
怎么了?我是否需要打开/关闭某个模式才能跳到下一个句号?如何检查哪些模式处于活动状态?
我正在慢慢改进PHP中的标点修复功能,用于清理用户输入.该函数当前在标点符号后添加空格,在标点符号之前删除空格,并将每个句子的第一个单词大写.我见过一些人正在寻找类似的功能,所以我很乐意分享到目前为止我所拥有的功能.它非常接近我想要它的位置,但是,当它在逗号后添加一个空格时,它应该避免这样做,当逗号在一个数字内,例如1,000时,任何人都可以建议最快的方法来修改我的代码以忽略数字中的逗号?也许有办法缩短我所拥有但仍然达到相同的结果?谢谢你的时间...
function format_punc($string){
$punctuation = ',.;:';
$string = str_replace(' ?', '?', str_replace(' .', '.', str_replace(' ,', ',', preg_replace('/(['.$punctuation.'])[\s]*/', '\1 ', $string))));
$string = trim(preg_replace('/[[:space:]]+/', ' ', preg_replace('/([\.!\?]\s+|\A)(\w)/e', '"$1" . strtoupper("$2")', $string)));
if($string[strlen($string)-1]==','){
$string = substr($string, 0, -1).'.';
}
return $string;
}
Run Code Online (Sandbox Code Playgroud) import java.util.Scanner;
public class Ex3 {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.print("Please input a word: ");
String Line = keyboard.nextLine();
boolean x = isReverse(Line);
System.out.print("It is " + x + " that this word is a palindrome.");
}
public static boolean isReverse(String Line) {
int length = Line.length();
boolean x = true;
String s = "";
for (int i = 0; i < length; i++) {
if (Line.charAt(i) != ' ') {
s += …Run Code Online (Sandbox Code Playgroud) 对于数字我可以写这样的矢量:
digits <- c("0","1","2","3","4","5","6","7","8","9")
Run Code Online (Sandbox Code Playgroud)
如何获得标点符号的类似向量?
所以我对c#有一个分配,我需要处理文本文件,用逗号分隔单词和其他标点符号.我选择这样做:
string Book1 = "@\\..\\Knyga1.txt";
string punctuation = " ,.?!;:\"";
string Read1 = File.ReadAllText(Book1);
string[] FirstFileWords = Read1.Split(punctuation.ToCharArray());
Run Code Online (Sandbox Code Playgroud)
但是我遇到了一个问题...我的文本文件应该像书一样,所以显然会有多行...有没有办法添加"输入密钥"或者我们称之为的东西为标点符号之一制作一个新行(对不起我的英语不好)?因为在以后处理单个单词时,例如打印出最长的单词,位于第2行3开头的单词等等在控制台中占用两行.
string.maketrans("","")
Run Code Online (Sandbox Code Playgroud)
给
\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13
\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~
\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90
\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2
\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4
\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9
\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde
\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed
\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff
Run Code Online (Sandbox Code Playgroud)
这是什么意思?
它如何通过以下调用帮助删除字符串中的标点符号:
import string
myStr.translate(string.maketrans("",""), string.punctuation)
Run Code Online (Sandbox Code Playgroud)