Linked Questions
24 questions linked to/from How can I strip all punctuation from a string in JavaScript using regex?
-3 votes
2 answers
14k views
Javascript regex to remove punctuation [duplicate]
I'm having trouble with my regex. I'm sure something is not escaping properly. function regex(str) { str = str.replace(/(~|`|!|@|#|$|%|^|&|*|\(|\)|{|}|\[|\]|;|:|\"|'|<|,|\.|>|\?|\...
0 votes
2 answers
779 views
Disallow punctuation in input [duplicate]
I am wondering if it is possible to create a regular expression which will allow digits, letters and spaces but no punctuation. Whats happening is I have an online loan application and in the street ...
0 votes
2 answers
65 views
How would I convert the text inside this class to just an int? [duplicate]
I'm making some code that scans an item for its price, and the price is located inside a class "cash". The text inside the cash class looks like this 1,000 I ...
0 votes
0 answers
30 views
regex how to find /,-,/s,,,! in one example? [duplicate]
How to find non letters from expression ? example string " friday is piątek, but in different language!" i did that but without efford : elem1 = element.replace(/\s/g, ''); elem2 = elem1.replace(/\-/...
875 votes
41 answers
800k views
How to count string occurrence in string?
How can I count the number of times a particular string occurs in another string. For example, this is what I am trying to do in Javascript: var temp = "This is a string."; alert(temp.count("is")); //...
803 votes
27 answers
781k views
Regex to replace multiple spaces with a single space
Given a string like: "The dog has a long tail, and it is RED!" What kind of jQuery or JavaScript magic can be used to keep spaces to only one space max? Goal: "The dog has a long tail,...
15 votes
8 answers
15k views
Why this regex is not working for german words?
I am trying to break the following sentence in words and wrap them in span. <p class="german_p big">Das ist ein schönes Armband</p> I followed this: How to get a word under cursor using ...
6 votes
8 answers
53k views
How to check if a string contains a WORD in javascript? [duplicate]
So, you can easily check if a string contains a particular substring using the .includes() method. I'm interested in finding if a string contains a word. For example, if I apply a search for "on" ...
4 votes
7 answers
5k views
Remove space before punctuation javascript/jquery
I want to remove space before every punctuation in Javascript/jquery. For example Input string = " This 's a test string ." Output = "This's a test string."
1 vote
2 answers
9k views
How to remove *.*, */* from string in JavaScript
I need to remove fractional addresses from a street address input line. I need to allow for people who enter strings like the following: 1600 1/2 Main St 1600 3/4 Main Street 1600.5 Main St 1600.75 ...
0 votes
6 answers
3k views
Using jQuery to find <em> tags and adding content within them
The users on my review type of platform highlight titles (of movies, books etc) in <em class="title"> tags. So for example, it could be: <em class="title">Pacific Rim&...
0 votes
2 answers
3k views
How to detect number, uppercase, lowercase data in string using JavaScript?
How to detect number, uppercase, lowercase data in string using JavaScript ? Why does this code tell me $, # and ! are upper/lower case ? How can I detect only number, uppercase, lowercase ? https:/...
0 votes
2 answers
1k views
what is best way to match words from list to words from sentence in javascript?
i have two sentences and i would like to find all the words they share regardless of capitalization or punctuation. currently this is what I am doing: searchWords = sentence1.split(" "); var ...
0 votes
3 answers
543 views
Parsing a string into words with no-english characters and puntuation
I am trying to split a string into an array of single words in Javascript. First step was quite easy: words = text.split(/\b\s+(?!$)/); This solution works fine, except it doesn't use punctuation ...
2 votes
1 answer
529 views
Get Chinese punctuation in a string
With the answers in Javascript unicode string, chinese character but no punctuation and How can I strip all punctuation from a string in JavaScript using regex? I have gotten close to what I need: ...
3 votes
2 answers
391 views
Javascript Equivalent of PHP's regex for punctuation
I'm using the following line of PHP to remove punctuation from strings: $key = preg_replace("/\p{P}/u", "", $key); Does anyone know how to do the same thing in Javascript/jQuery? I know you can use ...
1 vote
2 answers
91 views
Remove all punctuation from string except for ' character
Following this question How can I strip all punctuation from a string in JavaScript using regex? I'm trying to remove all punctuation from a string besides the ' character to avoid messing with words ...
0 votes
3 answers
117 views
RegExp problem - How do I remove punctuation and whitespaces?
I am trying to solve a palindrome problem. The palindrome can contain letters and numbers, but everything else must be removed. My code below is not returning the correct result. function palindrome(...
0 votes
1 answer
140 views
Message filter ignoring allowed words
I've been trying to redo a message filter for a little while now, and I'm stumped on something with it. I have a list of different words in different categories that the filter blocks, but there's ...
1 vote
1 answer
149 views
Check for Palindromes on freecode camp (don't want solution)
I want to be clear I'm not looking for solutions. I'm really trying to understand what is being done. With that said all pointers and recommendations are welcomed. I am woking through freecodecamp.com ...
1 vote
1 answer
77 views
How do I test if a string kind of equals another javascript
Say I have var string1 = "Hello" and string2 = "Hello" How can I compare these two and ignore the capitals and the punctuation in javascript?
0 votes
1 answer
86 views
Best way to remove these chars from javascript string
I'm looking for a way to remove these characters from a string in javascript (and spaces). ?[]/\=<>:;,'\"&$#*()|~`!{} I am unsure how to construct this: "mystring is - ?[] hello ".replace(...
-1 votes
2 answers
48 views
How to differentiate each of the character in string
I got a question in vb.net can I identify each of the character in string for an example i got a string of "Hello!. Good Afternoon!" from this string can i trim away the period symbol? Thank you
0 votes
1 answer
21 views
Have an issued with the functionality of a search over text not dealing well with punctuation/symbols. Jquery/Jquery mobile
So here is my current js fiddle http://jsfiddle.net/sbyLb93n/6/ I have tried adding .replace(/\W*/mg, "") to wordsArr and valuesArr before I turn the string of text into an array of strings ...