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: ...