Punctuation's are the marks, such as full stop, comma, and brackets, used in writing to separate sentences and their elements and to clarify meaning.
Questions tagged [punctuation]
451 questions
823
votes
32 answers
Best way to strip punctuation from a string
It seems like there should be a simpler way than:
import string
s = "string. With. Punctuation?" # Sample string
out = s.translate(string.maketrans("",""), string.punctuation)
Is there?

Redwood
- 66,744
- 41
- 126
- 187
57
votes
5 answers
In Erlang, when do I use ; or , or .?
I have been trying to learn Erlang and have been running into some problems with ending lines in functions and case statements.
When do I use a semicolon (;), comma (,), or period inside my functions or case statements?

samoz
- 56,849
- 55
- 141
- 195
38
votes
3 answers
How to read a .csv file containing apostrophes into R?
I am having difficulty getting R to read a .txt or .csv file that contains apostrophes.
Some of my columns contain descriptive text, such as "Attends to customers' needs" or "Sheriff's deputy". My file opens correctly in Excel (that is, all the…

user1257313
- 1,057
- 4
- 11
- 10
32
votes
4 answers
Remove all punctuation except apostrophes in R
I'd like to use R's gsub to remove all punctuation from a text except for apostrophes. I'm fairly new to regex but am learning.
Example:
x <- "I like %$@to*&, chew;: gum, but don't like|}{[] bubble@#^)( gum!?"
gsub("[[:punct:]]", "",…

Tyler Rinker
- 108,132
- 65
- 322
- 519
31
votes
3 answers
Remove punctuation from string with Regex
I'm really bad with Regex but I want to remove all these .,;:'"$#@!?/\*&^-+ out of a string.
string x = "This is a test string, with lots of: punctuations; in it?!.";
How can I do that?

Sjemmie
- 1,249
- 8
- 26
- 31
25
votes
4 answers
Regex punctuation split [Python]
Can anyone help me a bit with regexs? I currently have this: re.split(" +", line.rstrip()), which separates by spaces.
How could I expand this to cover punctuation, too?

dantdj
- 1,237
- 3
- 19
- 40
24
votes
5 answers
What is '`' character called?
I feel silly for asking this but it isn't like I could google this.
What is the ` character called? In case it doesnt show up, it is the character used for inline code with markdown. Also, on most keyboards, it shares the key with ~.
I like all…
user34537
22
votes
7 answers
Check if string is a punctuation character
Let's say I have a String array that contains some letters and punctuation
String letter[] = {"a","b","c",".","a"};
In letter[3] we have "."
How can I check if a string is a punctuation character?
We know that there are many possible punctuation…

sephtian
- 445
- 2
- 11
- 23
21
votes
1 answer
How do I strip all leading and trailing punctuation in Python?
I know how to remove all the punctuation in a string.
import string
s = '.$ABC-799-99,#'
table = string.maketrans("","") # to remove punctuation
new_s = s.translate(table, string.punctuation)
print(new_s)
# Output
ABC79999
How do I strip all…

SparkAndShine
- 17,001
- 22
- 90
- 134
21
votes
5 answers
Using Exclamation Marks '!' in C
I have come across a problem involving exclamation marks and integers whilst reading a code in my reference book.
Let us say I have declared an integer variable named number - int number = 0;
I then use a while function involving an exclamation mark…

Paul Filch
- 867
- 2
- 7
- 13
19
votes
12 answers
C++ Remove punctuation from String
I got a string and I want to remove all the punctuations from it. How do I do that? I did some research and found that people use the ispunct() function (I tried that), but I cant seem to get it to work in my code. Anyone got any ideas?
#include…

NewFile
- 501
- 5
- 10
- 16
17
votes
1 answer
Redefining "sentence" in Emacs? (single space between sentences, but ignoring abbreviations)
I would like to be able to navigate by sentence in Emacs (M-a, M-e). Here's the problem: by default, Emacs expects that each sentence is separated by two spaces, and I'm used to just putting a single space. Of course, that setting can be turned off,…

emacsomancer
- 597
- 1
- 5
- 14
17
votes
2 answers
Filtering out strings that only contains digits and/or punctuation - python
I need to filter out only strings that contains only digits and/or a fix set of punctuation.
I've tried checking each character and then summing the Boolean conditions to check if it is equal to the len(str). Is there a more pythonic way to do…

alvas
- 115,346
- 109
- 446
- 738
17
votes
3 answers
Adding Apostrophe in a string - Matlab
I want to put an apostrophe in a string to denote the possessive but it ends the string, how can I put one in.

Tessa Danger Bamkin
- 305
- 1
- 3
- 8
14
votes
8 answers
SQL Server: How do you remove punctuation from a field?
Any one know a good way to remove punctuation from a field in SQL Server?
I'm thinking
UPDATE tblMyTable SET FieldName = REPLACE(REPLACE(REPLACE(FieldName,',',''),'.',''),'''' ,'')
but it seems a bit tedious when I intend on removing a large number…

Ev.
- 7,109
- 14
- 53
- 87