|
We do a lot of lexical processing with arbitrary strings which include arbitrary punctuation. I am divided as to whether to use magic characters/strings or symbolic constants.
The examples should be read as language-independent although most are Java....
Started by peter.murray.rust on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
CharConfig.Quotation, CharConfig.EmtpyString);
For general string processing , I wouldn't use special!):
s.replace("String", " ");
Than:
s.replace("String", S_SPACE);
I would take special care to use things like to deal with constants....
|
|
The sample string:
this!is.an?example
I want to match: this is an example.
I tried this:
<script type="text/javascript"> var string="this!is.an?example"; var pattern=/^\W/g; alert(string.match(pattern)); </script>
Started by ronik on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
If you want to split also on underscores, use this:
var words = "this!is.an?example_with|underscore....
Why you want to explicitly match , but if your goal is to strip all punctuation, this would work:
var except letters, digits and underscore.
|
|
For the hope-to-have-an-answer-in-30-seconds part of this question, I'm specifically looking for C#
But in the general case, what's the best way to strip punctuation in any language?
I should add: Ideally, the solutions won't require you to enumerate ...
Started by Tom Ritter on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
MyCharCollection....
Imagine is a regex.replace and have your regular expression with all the appropriate punctuation marks stripped = input.replaceAll("\\p{P}+", "");
The first version only looks at punctuation characters contained in ASCII.
|
Ask your Facebook Friends
|
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?
Started by Lawrence Johnston on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Punctuation....
Punctuation?" # Sample string out = re.sub('[%s]' % re.escape = "string.
I usually use something like this:
>>> s re, string s = "string.
punctuation) around, which will speed things up a bit.
|
|
I'm looking to remove all punctuation from a string and make all uppercase letters lower case in C, any suggestions?
Started by NickTFried on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Whenever you meet an "alpha char" ( isalpha ), use tolower to convert.
Whenever you meet a punctuation ( ispunct ), don't copy it to the output string.
Loop over the characters of the string.
|
|
I'm trying to split a string on its punctuation, but the string may contain URLs (which conveniently has all the typical punctuation marks).
I have a basic working knowledge of RegEx, but not enough to help me out here. This is what I was using when I...
Started by Magsol on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
I don't know what your source text is like but that MIGHT be a reliable... .
Is there a pattern that your non-URL punctuation marks follow? In most English sentences, many punctuation marks are followed (or sometimes preceeded) by a space character.
|
|
I'm trying to split a string up into words and punctuation, adding the punctuation to the list produced by the split.
For instance:
>>> c = "help, me" >>> print c.split() ['help,', 'me']
What I really want the list to look like is:
[...
Started by David A on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
Anything not explicitely]
","
So if you want to add the "," you can just do it after each iteration when you use the array', 'a', 'string', "!"]
So, I....
punctuation marks you want to use in the right half of the regular expression.
|
|
What I want to do is check for duplicated words right next to each other but even if there is punctuation in between.
For example:
Vivamus Vivamus diam, diam, Vivamus Vivamus diam, diam Vivamus
there should be 4 distinct hits here.
I can't figure out ...
Started by Keng on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
That means it would spot things like:
diam, diam....
You will need to use for the punctuation, but does include the captured punctuation in the first capture.
The (?: is a non-capturing parenthesis, meaning it won't store the matches .
|
|
Hey everyone,
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...
Started by Ev on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Ideally....
You can use regular expressions in SQL Server - here is an article based on SQL 2005:
http://msdn.microsoft.com/en-us/magazine/cc163473.aspx
If it's a one-off thing, I would use a C# + LINQ snippet use it on INSERT too...
|
|
This is not a programming question per se but a question about searching source code files, which help me in programming.
I use a search tool, X1, which quickly tells me which source code files contain some keywords I am looking for. However it doesn'...
Started by Abdu on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Moreover, you may need to use another tool to use these index, I use vim myself....
If you want to search code files efficiently for keywords and punctuation, consider the SD Source suited for a per project use in my opinion.
|