punctuation

How to keep the delimiter while using RegEx?

坚强是说给别人听的谎言 提交于 2020-01-14 07:59:27
问题 I did a question about punctuation and regex, but it was confusing. Supossing I have this text: String text = "wor.d1, :word2. wo,rd3? word4!"; I'm doing this: String parts[] = text.split(" "); And I have this: wor.d1, | :word2. | wor,d3? | word4!; What I need to do to have this? (Keep the the symbols at the borders, but only that I specify: .,!?: , not all). wor,d1 | , | : | word2 | . | wor,d3 | ? | word4 | ! UPDATE I'm getting some good results with these regex, but it's giving an empty

Whitespace before some punctuation characters in French: is there a CSS way to avoid lines breaking?

*爱你&永不变心* 提交于 2020-01-03 13:33:38
问题 For example, in this sentence, "Comment allez-vous ?", the question mark and the last word in the sentence are separated by a whitespace. When French text is written in a column, you will often get something like this: Elle zigzague pour empiéter sur des impostures ? Jacqueline porte chance. The line break happens between the last word of the sentence and the question mark, which is not desirable. Elle zigzague pour empiéter sur des impostures ? Jacqueline porte chance. Is there a way to

SQL Server: How do you remove punctuation from a field?

百般思念 提交于 2019-12-31 21:43:35
问题 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 of different characters for example: !@#$%^&*()<>:" Thanks in advance 回答1: Ideally, you would do this in an application language such as C# + LINQ as mentioned above. If you wanted to do it purely in T-SQL though, one way make things neater would

Regex to strip out everything but words and numbers (and latin chars)

北城以北 提交于 2019-12-25 10:47:10
问题 Im trying to clean a post string used in an ajax request (sanitize before db query) to allow only alphanumeric characters, spaces (1 per word, not multiple), can contain "-", and latin characters like "ç" and "é" without success, can anyone help or point me on the right direction? This is the regex I'm using so far: $string = preg_replace('/^[a-z0-9 àáâãäåçèéêëìíîïðñòóôõöøùúû-]+$/', '', mb_strtolower(utf8_encode($_POST['q']))); Thank you. 回答1: $string = mb_strtolower(utf8_encode($_POST['q']))

C# check to see if an input contains only lowercase letters a-z

风流意气都作罢 提交于 2019-12-25 08:47:26
问题 I'm stuck on a task of trying to print words that contain only lowercase letters a-z. I have already stripped out an inputted string if it contains any number 0-9 and if it contains an Uppercase letter: String[] textParts; textParts = text.Split(delimChars); for (int i = 0; i < textParts.Length; i++) //adds s to words list and checks for capitals { String s = textParts[i]; bool valid = true; foreach (char c in textParts[i]) { if (char.IsUpper(c)) { valid = false; break; } if (c >= '0' && c <=

PHP regular expression to match alpha-numeric strings with some (but not all) punctuation

自闭症网瘾萝莉.ら 提交于 2019-12-24 22:37:01
问题 I've written a regular expression in PHP to allow strings that are alpha-numeric with any punctuation except & or @ . Essentially, I need to allow anything on a standard American keyboard with the exception of those two characters. It took me a while to come up with the following regex, which seems to be doing what I need: if (ereg("[^]A-Za-z0-9\[!\"#$%'()*+,./:;<=>?^_`{|}~\-]", $test_string)) { // error message goes here } Which brings me to my question... is there a better, simpler, or more

Removing all characters but letters in a string

时光怂恿深爱的人放手 提交于 2019-12-24 05:47:10
问题 If I have a string "ja.v_,a" , how can I remove all non-letter characters to output "java" ? I have tried str = str.replaceAll("\\W", "" ) , but to no avail. 回答1: Could you try this one? System.out.println("ja.v_,a".replaceAll("[^a-zA-Z]", "")) //java 回答2: I would like to refer to this article and quote it: Regex examples and tutorials always give you the [a-zA-Z0-9]+ regex to "validate alphanumeric input". It is built-in in many validation frameworks. And it is so utterly wrong. This is a

Removing escaped entities from a String in Python [duplicate]

泄露秘密 提交于 2019-12-23 02:49:56
问题 This question already has answers here : Decode HTML entities in Python string? (5 answers) Closed 6 years ago . I've a huge csv file of tweets. I read them both into the computer and stored them in two separate dictionaries - one for negative tweets, one for positive. I wanted to read the file in and parse it to a dictionary whilst removing any punctuation marks. I've used this code: tweets = [] for (text, sentiment) in pos_tweets.items() + neg_tweets.items(): shortenedText = [e.lower() and

How to read a .csv file containing apostrophes into R?

▼魔方 西西 提交于 2019-12-21 03:09:10
问题 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 data appear in the correct cells; there are 3 columns and about 8000 rows, and there is no missing data). But when I ask R to read the file, this is what happens: data <-read.table("datafile.csv", sep=",", header=TRUE) Error in scan(file, what, nmax,

VB.NET Brackets () {} [] <>

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-19 02:47:07
问题 Can someone please fill in the blanks for me, including a brief description of use and perhaps a code snippet? I'm well aware of the top two in particular, but a little hazy on the last one especially: () - Used for calling a function, object instantiation, passing parameters, etc. {} - Used for defining and adding elements to arrays or sets. [] - Used for forcing an object to be treated as a type rather than keyword. <> - Used for... ? For Example, I see stuff like this all the time, but